window.phoenix&&(window.phoenix.buildInfo||(window.phoenix.buildInfo=[]),-1===window.phoenix.buildInfo.findIndex((t=>"Phoenix-platform"===t.MFE))&&window.phoenix.buildInfo.push({MFE:"Phoenix-platform",VERSION:"4f801c6",LASTCOMMITDATETIME:"2024-07-08T07:55:19+00:00"})) /*! * * ============= BUILD INFO ============= * MFE: Phoenix-platform * chunkName: service-clientlibs/authorization/authorization * VERSION: 4f801c6 * BRANCH: HEAD * COMMITHASH: 4f801c6a05dec11337fda6d090793eee14303a13 * LASTCOMMITDATETIME: 2024-07-08T07:55:19+00:00 * ============= If you're reading this, why not come work with us? https://www.t-mobile.com/careers ============= */,function(){var t={166:function(t,e){var r,n,i,s,a,o,h,u,c,l,f,p={userAgent:!1},d={},g=g||(r=Math,i=(n={}).lib={},s=i.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=i.WordArray=s.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||h).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=a<<24-(n+s)%4*8}else for(s=0;s>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=r.ceil(e/4)},clone:function(){var t=s.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new a.init(r,e/2)}},u=o.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new a.init(r,e)}},c=o.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=i.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,n=e.words,i=e.sigBytes,s=this.blockSize,o=i/(4*s),h=(o=t?r.ceil(o):r.max((0|o)-this._minBufferSize,0))*s,u=r.min(4*h,i);if(h){for(var c=0;c>>2]}},e.BlockCipher=o.extend({cfg:o.cfg.extend({mode:h,padding:c}),reset:function(){o.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=e.createEncryptor;else r=e.createDecryptor,this._minBufferSize=1;this._mode=r.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=r.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(p.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var r=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:r})}},e.SerializableCipher=r.extend({cfg:r.extend({format:h}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n);return e=i.finalize(e),i=i.cfg,l.create({ciphertext:e,key:r,iv:i.iv,algorithm:t,mode:i.mode,padding:i.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),p=(p.kdf={}).OpenSSL={execute:function(t,e,r,i){return i||(i=n.random(8)),t=a.create({keySize:e+r}).compute(t,i),r=n.create(t.words.slice(e),4*r),t.sigBytes=4*e,l.create({key:t,iv:r,salt:i})}},d=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:p}),encrypt:function(t,e,r,n){return r=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize),n.iv=r.iv,(t=f.encrypt.call(this,t,e,r.key,n)).mixIn(r),t},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),r=n.kdf.execute(r,t.keySize,t.ivSize,e.salt),n.iv=r.iv,f.decrypt.call(this,t,e,r.key,n)}})}(),function(){for(var t=g,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],s=[],a=[],o=[],h=[],u=[],c=[],l=[],f=[],p=[],d=0;256>d;d++)p[d]=128>d?d<<1:d<<1^283;var y=0,v=0;for(d=0;256>d;d++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[y]=m,i[m]=y;var x=p[y],w=p[x],S=p[w],b=257*p[m]^16843008*m;s[y]=b<<24|b>>>8,a[y]=b<<16|b>>>16,o[y]=b<<8|b>>>24,h[y]=b,b=16843009*S^65537*w^257*x^16843008*y,u[m]=b<<24|b>>>8,c[m]=b<<16|b>>>16,l[m]=b<<8|b>>>24,f[m]=b,y?(y=x^p[p[p[S^x]]],v^=p[p[v]]):y=v=1}var E=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){for(var t=(r=this._key).words,e=r.sigBytes/4,r=4*((this._nRounds=e+6)+1),i=this._keySchedule=[],s=0;s>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a]):(a=n[(a=a<<8|a>>>24)>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a],a^=E[s/e|0]<<24),i[s]=i[s-e]^a}for(t=this._invKeySchedule=[],e=0;ee||4>=s?a:u[n[a>>>24]]^c[n[a>>>16&255]]^l[n[a>>>8&255]]^f[n[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,o,h,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,i),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,s,a,o){for(var h=this._nRounds,u=t[e]^r[0],c=t[e+1]^r[1],l=t[e+2]^r[2],f=t[e+3]^r[3],p=4,d=1;d>>24]^i[c>>>16&255]^s[l>>>8&255]^a[255&f]^r[p++],y=n[c>>>24]^i[l>>>16&255]^s[f>>>8&255]^a[255&u]^r[p++],v=n[l>>>24]^i[f>>>16&255]^s[u>>>8&255]^a[255&c]^r[p++];f=n[f>>>24]^i[u>>>16&255]^s[c>>>8&255]^a[255&l]^r[p++],u=g,c=y,l=v}g=(o[u>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&f])^r[p++],y=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[f>>>8&255]<<8|o[255&u])^r[p++],v=(o[l>>>24]<<24|o[f>>>16&255]<<16|o[u>>>8&255]<<8|o[255&c])^r[p++],f=(o[f>>>24]<<24|o[u>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^r[p++],t[e]=g,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(r)}(),function(){function t(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<r;r++){var n=a[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var i=t[n]=[],s=h[n];for(r=0;24>r;r++)i[r/6|0]|=e[(o[r]-1+s)%28]<<31-r%6,i[4+(r/6|0)]|=e[28+(o[r+24]-1+s)%28]<<31-r%6;for(i[0]=i[0]<<1|i[0]>>>31,r=1;7>r;r++)i[r]>>>=4*(r-1)+3;i[7]=i[7]<<5|i[7]>>>27}for(e=this._invSubKeys=[],r=0;16>r;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(r,n,i){this._lBlock=r[n],this._rBlock=r[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var a=i[s],o=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^a[f])&c[f])>>>0];this._lBlock=h,this._rBlock=o^l}i=this._lBlock,this._lBlock=this._rBlock,this._rBlock=i,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),r[n]=this._lBlock,r[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(l),s=s.TripleDES=i.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(s)}(),function(){var t=g,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,n=this._map;t.clamp(),t=[];for(var i=0;i>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;4>a&&i+.75*a>>6*(3-a)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,n=this._map;(i=n.charAt(64))&&(-1!=(i=t.indexOf(i))&&(r=i));for(var i=[],s=0,a=0;a>>6-a%4*2;i[s>>>2]|=(o|h)<<24-s%4*8,s++}return e.create(i,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,n,i,s,a){return((t=t+(e&r|~e&n)+i+a)<>>32-s)+e}function r(t,e,r,n,i,s,a){return((t=t+(e&n|r&~n)+i+a)<>>32-s)+e}function n(t,e,r,n,i,s,a){return((t=t+(e^r^n)+i+a)<>>32-s)+e}function i(t,e,r,n,i,s,a){return((t=t+(r^(e|~n))+i+a)<>>32-s)+e}for(var s=g,a=(h=s.lib).WordArray,o=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var a=0;16>a;a++){var o=t[h=s+a];t[h]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}a=this._hash.words;var h=t[s+0],c=(o=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],p=t[s+5],d=t[s+6],g=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],x=t[s+11],w=t[s+12],S=t[s+13],b=t[s+14],E=t[s+15],F=e(F=a[0],I=a[1],P=a[2],A=a[3],h,7,u[0]),A=e(A,F,I,P,o,12,u[1]),P=e(P,A,F,I,c,17,u[2]),I=e(I,P,A,F,l,22,u[3]);F=e(F,I,P,A,f,7,u[4]),A=e(A,F,I,P,p,12,u[5]),P=e(P,A,F,I,d,17,u[6]),I=e(I,P,A,F,g,22,u[7]),F=e(F,I,P,A,y,7,u[8]),A=e(A,F,I,P,v,12,u[9]),P=e(P,A,F,I,m,17,u[10]),I=e(I,P,A,F,x,22,u[11]),F=e(F,I,P,A,w,7,u[12]),A=e(A,F,I,P,S,12,u[13]),P=e(P,A,F,I,b,17,u[14]),F=r(F,I=e(I,P,A,F,E,22,u[15]),P,A,o,5,u[16]),A=r(A,F,I,P,d,9,u[17]),P=r(P,A,F,I,x,14,u[18]),I=r(I,P,A,F,h,20,u[19]),F=r(F,I,P,A,p,5,u[20]),A=r(A,F,I,P,m,9,u[21]),P=r(P,A,F,I,E,14,u[22]),I=r(I,P,A,F,f,20,u[23]),F=r(F,I,P,A,v,5,u[24]),A=r(A,F,I,P,b,9,u[25]),P=r(P,A,F,I,l,14,u[26]),I=r(I,P,A,F,y,20,u[27]),F=r(F,I,P,A,S,5,u[28]),A=r(A,F,I,P,c,9,u[29]),P=r(P,A,F,I,g,14,u[30]),F=n(F,I=r(I,P,A,F,w,20,u[31]),P,A,p,4,u[32]),A=n(A,F,I,P,y,11,u[33]),P=n(P,A,F,I,x,16,u[34]),I=n(I,P,A,F,b,23,u[35]),F=n(F,I,P,A,o,4,u[36]),A=n(A,F,I,P,f,11,u[37]),P=n(P,A,F,I,g,16,u[38]),I=n(I,P,A,F,m,23,u[39]),F=n(F,I,P,A,S,4,u[40]),A=n(A,F,I,P,h,11,u[41]),P=n(P,A,F,I,l,16,u[42]),I=n(I,P,A,F,d,23,u[43]),F=n(F,I,P,A,v,4,u[44]),A=n(A,F,I,P,w,11,u[45]),P=n(P,A,F,I,E,16,u[46]),F=i(F,I=n(I,P,A,F,c,23,u[47]),P,A,h,6,u[48]),A=i(A,F,I,P,g,10,u[49]),P=i(P,A,F,I,b,15,u[50]),I=i(I,P,A,F,p,21,u[51]),F=i(F,I,P,A,w,6,u[52]),A=i(A,F,I,P,l,10,u[53]),P=i(P,A,F,I,m,15,u[54]),I=i(I,P,A,F,o,21,u[55]),F=i(F,I,P,A,y,6,u[56]),A=i(A,F,I,P,E,10,u[57]),P=i(P,A,F,I,d,15,u[58]),I=i(I,P,A,F,S,21,u[59]),F=i(F,I,P,A,f,6,u[60]),A=i(A,F,I,P,x,10,u[61]),P=i(P,A,F,I,c,15,u[62]),I=i(I,P,A,F,v,21,u[63]);a[0]=a[0]+F|0,a[1]=a[1]+I|0,a[2]=a[2]+P|0,a[3]=a[3]+A|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var s=t.floor(n/4294967296);for(r[15+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(i+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(r.length+1),this._process(),r=(e=this._hash).words,n=0;4>n;n++)i=r[n],r[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return e},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=o._createHelper(h),s.HmacMD5=o._createHmacHelper(h)}(Math),function(){var t=g,e=(i=t.lib).WordArray,r=i.Hasher,n=[],i=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],s=r[1],a=r[2],o=r[3],h=r[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(i<<5|i>>>27)+h+n[u],c=20>u?c+(1518500249+(s&a|~s&o)):40>u?c+(1859775393+(s^a^o)):60>u?c+((s&a|s&o|a&o)-1894007588):c+((s^a^o)-899497514),h=o,o=a,a=s<<30|s>>>2,s=i,i=c}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(i),t.HmacSHA1=r._createHmacHelper(i)}(),function(t){for(var e=g,r=(i=e.lib).WordArray,n=i.Hasher,i=e.algo,s=[],a=[],o=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=o(t.pow(h,.5))),a[u]=o(t.pow(h,1/3)),u++),h++}var p=[];i=i.SHA256=n.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],h=r[4],u=r[5],c=r[6],l=r[7],f=0;64>f;f++){if(16>f)p[f]=0|t[e+f];else{var d=p[f-15],g=p[f-2];p[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+p[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+p[f-16]}d=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+a[f]+p[f],g=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&i^n&s^i&s),l=c,c=u,u=h,h=o+d|0,o=s,s=i,i=n,n=d+g|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0,r[5]=r[5]+u|0,r[6]=r[6]+c|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(i),e.HmacSHA256=n._createHmacHelper(i)}(Math),function(){var t=g,e=t.lib.WordArray,r=(n=t.algo).SHA256,n=n.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(n),t.HmacSHA224=r._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=g,r=e.lib.Hasher,n=(s=e.x64).Word,i=s.WordArray,s=e.algo,a=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],o=[],h=0;80>h;h++)o[h]=t();s=s.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(l=this._hash.words)[0],n=l[1],i=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=r.high,p=r.low,d=n.high,g=n.low,y=i.high,v=i.low,m=s.high,x=s.low,w=h.high,S=h.low,b=u.high,E=u.low,F=c.high,A=c.low,P=l.high,I=l.low,T=f,D=p,C=d,R=g,N=y,O=v,B=m,H=x,j=w,k=S,_=b,V=E,L=F,K=A,M=P,q=I,U=0;80>U;U++){var G=o[U];if(16>U)var z=G.high=0|t[e+2*U],$=G.low=0|t[e+2*U+1];else{z=(($=(z=o[U-15]).high)>>>1|(J=z.low)<<31)^($>>>8|J<<24)^$>>>7;var J=(J>>>1|$<<31)^(J>>>8|$<<24)^(J>>>7|$<<25),W=(($=(W=o[U-2]).high)>>>19|(X=W.low)<<13)^($<<3|X>>>29)^$>>>6,X=(X>>>19|$<<13)^(X<<3|$>>>29)^(X>>>6|$<<26),Z=($=o[U-7]).high,Y=(Q=o[U-16]).high,Q=Q.low;z=(z=(z=z+Z+(($=J+$.low)>>>0>>0?1:0))+W+(($=$+X)>>>0>>0?1:0))+Y+(($=$+Q)>>>0>>0?1:0);G.high=z,G.low=$}Z=j&_^~j&L,Q=k&V^~k&K,G=T&C^T&N^C&N;var tt=D&R^D&O^R&O,et=(J=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),W=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),(X=a[U]).high),rt=X.low;Y=M+((j>>>14|k<<18)^(j>>>18|k<<14)^(j<<23|k>>>9))+((X=q+((k>>>14|j<<18)^(k>>>18|j<<14)^(k<<23|j>>>9)))>>>0>>0?1:0),M=L,q=K,L=_,K=V,_=j,V=k,j=B+(Y=(Y=(Y=Y+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+rt)>>>0>>0?1:0))+z+((X=X+$)>>>0<$>>>0?1:0))+((k=H+X|0)>>>0>>0?1:0)|0,B=N,H=O,N=C,O=R,C=T,R=D,T=Y+(G=J+G+(($=W+tt)>>>0>>0?1:0))+((D=X+$|0)>>>0>>0?1:0)|0}p=r.low=p+D,r.high=f+T+(p>>>0>>0?1:0),g=n.low=g+R,n.high=d+C+(g>>>0>>0?1:0),v=i.low=v+O,i.high=y+N+(v>>>0>>0?1:0),x=s.low=x+H,s.high=m+B+(x>>>0>>0?1:0),S=h.low=S+k,h.high=w+j+(S>>>0>>0?1:0),E=u.low=E+V,u.high=b+_+(E>>>0>>0?1:0),A=c.low=A+K,c.high=F+L+(A>>>0>>0?1:0),I=l.low=I+q,l.high=P+M+(I>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(s),e.HmacSHA512=r._createHmacHelper(s)}(),function(){var t=g,e=(i=t.x64).Word,r=i.WordArray,n=(i=t.algo).SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(i),t.HmacSHA384=n._createHmacHelper(i)}(),function(){var t=g,e=(n=t.lib).WordArray,r=n.Hasher,n=t.algo,i=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),o=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var n=t[w=e+r];t[w]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,p,d,g,y,v,m,x,w=this._hash.words,S=(n=h.words,u.words),b=i.words,E=s.words,F=a.words,A=o.words;g=c=w[0],y=l=w[1],v=f=w[2],m=p=w[3],x=d=w[4];var P;for(r=0;80>r;r+=1)P=c+t[e+b[r]]|0,P=16>r?P+((l^f^p)+n[0]):32>r?P+((l&f|~l&p)+n[1]):48>r?P+(((l|~f)^p)+n[2]):64>r?P+((l&p|f&~p)+n[3]):P+((l^(f|~p))+n[4]),P=(P=(P|=0)<>>32-F[r])+d|0,c=d,d=p,p=f<<10|f>>>22,f=l,l=P,P=g+t[e+E[r]]|0,P=16>r?P+((y^(v|~m))+S[0]):32>r?P+((y&m|v&~m)+S[1]):48>r?P+(((y|~v)^m)+S[2]):64>r?P+((y&v|~y&m)+S[3]):P+((y^v^m)+S[4]),P=(P=(P|=0)<>>32-A[r])+x|0,g=x,x=m,m=v<<10|v>>>22,v=y,y=P;P=w[1]+f+m|0,w[1]=w[2]+p+x|0,w[2]=w[3]+d+g|0,w[3]=w[4]+c+y|0,w[4]=w[0]+l+v|0,w[0]=P},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;5>r;r++)n=e[r],e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=r._createHelper(n),t.HmacRIPEMD160=r._createHmacHelper(n)}(Math),function(){var t=g,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,r){t=this._hasher=new t.init,"string"==typeof r&&(r=e.parse(r));var n=t.blockSize,i=4*n;r.sigBytes>i&&(r=t.finalize(r)),r.clamp();for(var s=this._oKey=r.clone(),a=this._iKey=r.clone(),o=s.words,h=a.words,u=0;u>6)+v.charAt(63&r);if(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=v.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=v.charAt(r>>2)+v.charAt((3&r)<<4)),m)for(;(3&n.length)>0;)n+=m;return n}function w(t){var e,r,n,i="",s=0;for(e=0;e>2),r=3&n,s=1):1==s?(i+=T(r<<2|n>>4),r=15&n,s=2):2==s?(i+=T(r),i+=T(n>>2),r=3&n,s=3):(i+=T(r<<2|n>>4),i+=T(15&n),s=0));return 1==s&&(i+=T(r<<2)),i}function S(t){var e,r=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=o*h+u*a;i=((h=a*h+((32767&c)<<15)+r[n]+(1073741823&i))>>>30)+(c>>>15)+o*u+(i>>>30),r[n++]=1073741823&h}return i},y=30):"Netscape"!=p.appName?(b.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var a=e*this[t++]+r[n]+i;i=Math.floor(a/67108864),r[n++]=67108863&a}return i},y=26):(b.prototype.am=function(t,e,r,n,i,s){for(var a=16383&e,o=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=o*h+u*a;i=((h=a*h+((16383&c)<<14)+r[n]+i)>>28)+(c>>14)+o*u,r[n++]=268435455&h}return i},y=28),b.prototype.DB=y,b.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function N(t){this.m=t}function O(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function V(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function L(){}function K(t){return t}function M(t){this.r2=E(),this.q3=E(),b.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}N.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},N.prototype.revert=function(t){return t},N.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},N.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},O.prototype.convert=function(t){var e=E();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(b.ZERO)>0&&this.m.subTo(e,e),e},O.prototype.revert=function(t){var e=E();return t.copyTo(e),this.reduce(e),e},O.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},O.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},O.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},b.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},b.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},b.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var a=8==r?255&t[n]:D(t,n);a<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},b.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},b.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+a+1]=this[r]>>i|o,o=(this[r]&s)<=0;--r)e[r]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},b.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var a=r+1;a>n;n>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},b.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},b.prototype.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(h,s),i.lShiftTo(h,r)):(n.copyTo(s),i.copyTo(r));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,p=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),b.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=r[--g]==c?this.DM:Math.floor(r[g]*f+(r[g-1]+d)*p);if((r[g]+=s.am(0,m,r,y,0,u))0&&r.rShiftTo(h,r),a<0&&b.ZERO.subTo(r,r)}}},b.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},b.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},b.prototype.exp=function(t,e){if(t>4294967295||t<1)return b.ONE;var r=E(),n=E(),i=e.convert(this),s=R(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var a=r;r=n,n=a}return e.revert(r)},b.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(o>o)>0&&(i=!0,s=T(r));a>=0;)o>(o+=this.DB-e)):(r=this[a]>>(o-=e)&n,o<=0&&(o+=this.DB,--a)),r>0&&(i=!0),i&&(s+=T(r));return i?s:"0"},b.prototype.negate=function(){var t=E();return b.ZERO.subTo(this,t),t},b.prototype.abs=function(){return this.s<0?this.negate():this},b.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},b.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+R(this[this.t-1]^this.s&this.DM)},b.prototype.mod=function(t){var e=E();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(b.ZERO)>0&&t.subTo(e,e),e},b.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new N(e):new O(e),this.exp(t,r)},b.ZERO=C(0),b.ONE=C(1),L.prototype.convert=K,L.prototype.revert=K,L.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},L.prototype.sqrTo=function(t,e){t.squareTo(e)},M.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=E();return t.copyTo(e),this.reduce(e),e},M.prototype.revert=function(t){return t},M.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},M.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},M.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],U=(1<<26)/q[q.length-1]; /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */ function G(){this.i=0,this.j=0,this.S=new Array}b.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},b.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=C(r),i=E(),s=E(),a="";for(this.divRemTo(n,i,s);i.signum()>0;)a=(r+s.intValue()).toString(t).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(t)+a},b.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,a=0,o=0;o=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),i&&b.ZERO.subTo(this,this)},b.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(b.ONE.shiftLeft(t-1),H,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(b.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},b.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},b.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},b.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},b.prototype.millerRabin=function(t){var e=this.subtract(b.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>q.length&&(t=q.length);for(var i=E(),s=0;s>24},b.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},b.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},b.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&r&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},b.prototype.equals=function(t){return 0==this.compareTo(t)},b.prototype.min=function(t){return this.compareTo(t)<0?this:t},b.prototype.max=function(t){return this.compareTo(t)>0?this:t},b.prototype.and=function(t){var e=E();return this.bitwiseTo(t,B,e),e},b.prototype.or=function(t){var e=E();return this.bitwiseTo(t,H,e),e},b.prototype.xor=function(t){var e=E();return this.bitwiseTo(t,j,e),e},b.prototype.andNot=function(t){var e=E();return this.bitwiseTo(t,k,e),e},b.prototype.not=function(){for(var t=E(),e=0;e=this.t?0!=this.s:!!(this[e]&1<1){var c=E();for(n.sqrTo(a[1],c);o<=u;)a[o]=E(),n.mulTo(c,a[o-2],a[o]),o+=2}var l,f,p=t.t-1,d=!0,g=E();for(i=R(t[p])-1;p>=0;){for(i>=h?l=t[p]>>i-h&u:(l=(t[p]&(1<0&&(l|=t[p-1]>>this.DB+i-h)),o=r;!(1&l);)l>>=1,--o;if((i-=o)<0&&(i+=this.DB,--p),d)a[l].copyTo(s),d=!1;else{for(;o>1;)n.sqrTo(s,g),n.sqrTo(g,s),o-=2;o>0?n.sqrTo(s,g):(f=s,s=g,g=f),n.mulTo(g,a[l],s)}for(;p>=0&&!(t[p]&1<=0?(r.subTo(n,r),e&&i.subTo(a,i),s.subTo(o,s)):(n.subTo(r,n),e&&a.subTo(i,a),o.subTo(s,o))}return 0!=n.compareTo(b.ONE)?b.ZERO:o.compareTo(t)>=0?o.subtract(t):o.signum()<0?(o.addTo(t,o),o.signum()<0?o.add(t):o):o},b.prototype.pow=function(t){return this.exp(t,new L)},b.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},b.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=q[q.length-1]){for(e=0;e>8&255,$[J++]^=t>>16&255,$[J++]^=t>>24&255,J>=W&&(J-=W)}((new Date).getTime())}if(null==$){var Z;if($=new Array,J=0,void 0!==d&&(void 0!==d.crypto||void 0!==d.msCrypto)){var Y=d.crypto||d.msCrypto;if(Y.getRandomValues){var Q=new Uint8Array(32);for(Y.getRandomValues(Q),Z=0;Z<32;++Z)$[J++]=Q[Z]}else if("Netscape"==p.appName&&p.appVersion<"5"){var tt=d.crypto.random(32);for(Z=0;Z>>8,$[J++]=255&Z;J=0,X()}function et(){if(null==z){for(X(),(z=new G).init($),J=0;J<$.length;++J)$[J]=0;J=0}return z.next()}function rt(){} /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */ function nt(t,e){return new b(t,e)}function it(t,e,r){for(var n="",i=0;n.length>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return n}function st(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,r){for(var n="",i=0;n.length>24,(16711680&i)>>16,(65280&i)>>8,255&i])),i+=1;return n} /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */ function ot(t,e){this.x=e,this.q=t}function ht(t,e,r,n){this.curve=t,this.x=e,this.y=r,this.z=null==n?b.ONE:n,this.zinv=null}function ut(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new ht(this,null,null)}rt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=nt(t,16),this.e=parseInt(e,16)}},st.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var s=new rt,a=new Array;e>2;){for(a[0]=0;0==a[0];)s.nextBytes(a);r[--e]=a[0]}return r[--e]=2,r[--e]=0,new b(r)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n},st.prototype.encryptOAEP=function(t,e,r){var n=this.n.bitLength()+7>>3,i=function(t,e,r,n){var i=lt.crypto.MessageDigest,s=lt.crypto.Util,a=null;if(r||(r="sha1"),"string"==typeof r&&(a=i.getCanonicalAlgName(r),n=i.getHashLength(a),r=function(t){return Pt(s.hashHex(It(t),a))}),t.length+2*n+2>e)throw"Message too long for RSA";var o,h="";for(o=0;o0&&e.length>0))throw"Invalid RSA private key";this.n=nt(t,16),this.e=parseInt(e,16),this.d=nt(r,16)}},st.prototype.setPrivateEx=function(t,e,r,n,i,s,a,o){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=nt(t,16),this.e=parseInt(e,16),this.d=nt(r,16),this.p=nt(n,16),this.q=nt(i,16),this.dmp1=nt(s,16),this.dmq1=nt(a,16),this.coeff=nt(o,16)},st.prototype.generate=function(t,e){var r=new rt,n=t>>1;this.e=parseInt(e,16);for(var i=new b(e,16),s=t/2-100,a=b.ONE.shiftLeft(s);;){for(;this.p=new b(t-n,1,r),0!=this.p.subtract(b.ONE).gcd(i).compareTo(b.ONE)||!this.p.isProbablePrime(10););for(;this.q=new b(n,1,r),0!=this.q.subtract(b.ONE).gcd(i).compareTo(b.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.q.subtract(this.p).abs();if(!(h.bitLength()=r.length)return null;for(var i="";++n191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},st.prototype.decryptOAEP=function(t,e,r){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=nt(t,16),i=this.doPrivate(n);return null==i?null:function(t,e,r,n){var i=lt.crypto.MessageDigest,s=lt.crypto.Util,a=null;for(r||(r="sha1"),"string"==typeof r&&(a=i.getCanonicalAlgName(r),n=i.getHashLength(a),r=function(t){return Pt(s.hashHex(It(t),a))}),t=t.toByteArray(),o=0;o>3,e,r)},ot.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ot.prototype.toBigInteger=function(){return this.x},ot.prototype.negate=function(){return new ot(this.q,this.x.negate().mod(this.q))},ot.prototype.add=function(t){return new ot(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ot.prototype.subtract=function(t){return new ot(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ot.prototype.multiply=function(t){return new ot(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ot.prototype.square=function(){return new ot(this.q,this.x.square().mod(this.q))},ot.prototype.divide=function(t){return new ot(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ot.prototype.sqrt=function(){return new ot(this.q,this.x.sqrt().mod(this.q))},ht.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ht.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ht.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(b.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(b.ZERO))},ht.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(b.ZERO)&&!this.y.toBigInteger().equals(b.ZERO)},ht.prototype.negate=function(){return new ht(this.curve,this.x,this.y.negate(),this.z)},ht.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),r=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(b.ZERO.equals(r))return b.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new b("3"),i=this.x.toBigInteger(),s=this.y.toBigInteger(),a=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),o=a.multiply(r),h=i.multiply(a),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(o).multiply(r).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(o)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(o)).mod(this.curve.q),f=o.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ht(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ht.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new b("3"),e=this.x.toBigInteger(),r=this.y.toBigInteger(),n=r.multiply(this.z),i=n.multiply(r).mod(this.curve.q),s=this.curve.a.toBigInteger(),a=e.square().multiply(t);b.ZERO.equals(s)||(a=a.add(this.z.square().multiply(s)));var o=(a=a.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(i)).shiftLeft(1).multiply(n).mod(this.curve.q),h=a.multiply(t).multiply(e).subtract(i.shiftLeft(1)).shiftLeft(2).multiply(i).subtract(a.square().multiply(a)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ht(this.curve,this.curve.fromBigInteger(o),this.curve.fromBigInteger(h),u)},ht.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,n=r.multiply(new b("3")),i=this.negate(),s=this,a=this.curve.q.subtract(t),o=a.multiply(new b("3")),h=new ht(this.curve,this.x,this.y),u=h.negate();for(e=n.bitLength()-2;e>0;--e){s=s.twice();var c=n.testBit(e);c!=r.testBit(e)&&(s=s.add(c?this:i))}for(e=o.bitLength()-2;e>0;--e){h=h.twice();var l=o.testBit(e);l!=a.testBit(e)&&(h=h.add(l?h:u))}return s},ht.prototype.multiplyTwo=function(t,e,r){var n;n=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var i=this.curve.getInfinity(),s=this.add(e);n>=0;)i=i.twice(),t.testBit(n)?i=r.testBit(n)?i.add(s):i.add(this):r.testBit(n)&&(i=i.add(e)),--n;return i},ut.prototype.getQ=function(){return this.q},ut.prototype.getA=function(){return this.a},ut.prototype.getB=function(){return this.b},ut.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ut.prototype.getInfinity=function(){return this.infinity},ut.prototype.fromBigInteger=function(t){return new ot(this.q,t)},ut.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),r=(t.substr(2),this.fromBigInteger(new b(o,16))),n=this.getA(),i=this.getB(),s=r.square().add(n).multiply(r).add(i).sqrt();return"03"==e&&(s=s.negate()),new ht(this,r,s);case 4:case 6:case 7:var a=(t.length-2)/2,o=t.substr(2,a),h=t.substr(a+2,a);return new ht(this,this.fromBigInteger(new b(o,16)),this.fromBigInteger(new b(h,16)));default:return null}}, /*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib */ ot.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ht.prototype.getEncoded=function(t){var e=function(t,e){var r=t.toByteArrayUnsigned();if(er.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),i=e(r,32);return t?n.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(e(n,32))),i},ht.decodeFrom=function(t,e){e[0];var r=e.length-1,n=e.slice(1,1+r/2),i=e.slice(1+r/2,1+r);n.unshift(0),i.unshift(0);var s=new b(n),a=new b(i);return new ht(t,t.fromBigInteger(s),t.fromBigInteger(a))},ht.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,n=e.substr(2,r/2),i=e.substr(2+r/2,r/2),s=new b(n,16),a=new b(i,16);return new ht(t,t.fromBigInteger(s),t.fromBigInteger(a))},ht.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),n=r.square().subtract(this.x).subtract(t.x),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new ht(this.curve,n,i)},ht.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(b.valueOf(2)),e=this.curve.fromBigInteger(b.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=r.square().subtract(this.x.multiply(t)),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new ht(this.curve,n,i)},ht.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,n=r.multiply(new b("3")),i=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var a=n.testBit(e);a!=r.testBit(e)&&(s=s.add2D(a?this:i))}return s},ht.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),s=e.multiply(e).mod(i),a=t.multiply(t).multiply(t).add(r.multiply(t)).add(n).mod(i);return s.equals(a)},ht.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ht.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(b.ONE)<0||e.compareTo(t.subtract(b.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(b.ONE)<0||r.compareTo(t.subtract(b.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; /*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval */ var ct=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?r[e]:String.fromCharCode(parseInt(n,16))}var i=new String(""),s=Object.hasOwnProperty;return function(r,a){var o,h,u=r.match(t),c=u[0],l=!1;"{"===c?o={}:"["===c?o=[]:(o=[],l=!0);for(var f=[o],p=1-l,d=u.length;p=0;)delete r[n[h]]}return a.call(t,e,r)};o=y({"":o},"")}return o}}();void 0!==lt&<||(lt={}),void 0!==lt.asn1&<.asn1||(lt.asn1={}),lt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i15)throw new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},lt.asn1.DERAbstractString=function(t){lt.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=Et(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},ne(lt.asn1.DERAbstractString,lt.asn1.ASN1Object),lt.asn1.DERAbstractTime=function(t){lt.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var a=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var o=i.getMilliseconds();if(0!=o){var h=n(String(o),3);a=a+"."+(h=h.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,n,i,s){var a=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},ne(lt.asn1.DERAbstractTime,lt.asn1.ASN1Object),lt.asn1.DERAbstractStructured=function(t){lt.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},ne(lt.asn1.DERAbstractStructured,lt.asn1.ASN1Object),lt.asn1.DERBoolean=function(t){lt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},ne(lt.asn1.DERBoolean,lt.asn1.ASN1Object),lt.asn1.DERInteger=function(t){lt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=lt.asn1.ASN1Util.bigIntToMinTwosComplementsHex;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,r=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)return this.hV=t.hex,this.hV;if("number"==typeof t)r=new b(String(t),10);else if(null!=t.int)r=new b(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");r=t.bigint}return this.hV=e(r),this.hV},null!=t&&(this.params=t)},ne(lt.asn1.DERInteger,lt.asn1.ASN1Object),lt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=lt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}lt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7>6).toString(16)+n.toString(16))}n=128|(15&e)<<2|(192&r)>>6;var i=128|63&r;return Ft((224|(240&e)>>4).toString(16)+n.toString(16)+i.toString(16))}));return e.join("")}function Gt(t){for(var e=encodeURIComponent(t),r="",n=0;n"7"?"00"+t:t}dt.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0=n)break}return a},dt.getNthChildIdx=function(t,e,r){return dt.getChildIdx(t,e)[r]},dt.getIdxbyList=function(t,e,r,n){var i,s,a=dt;return 0==r.length?void 0!==n&&t.substr(e,2)!==n?-1:e:(i=r.shift())>=(s=a.getChildIdx(t,e)).length?-1:a.getIdxbyList(t,s[i],r,n)},dt.getIdxbyListEx=function(t,e,r,n){var i,s,a=dt;if(0==r.length)return void 0!==n&&t.substr(e,2)!==n?-1:e;i=r.shift(),s=a.getChildIdx(t,e);for(var o=0,h=0;h=t.length?null:i.getTLV(t,s)},dt.getTLVbyListEx=function(t,e,r,n){var i=dt,s=i.getIdxbyListEx(t,e,r,n);return-1==s?null:i.getTLV(t,s)},dt.getVbyList=function(t,e,r,n,i){var s,a,o=dt;return-1==(s=o.getIdxbyList(t,e,r,n))||s>=t.length?null:(a=o.getV(t,s),!0===i&&(a=a.substr(2)),a)},dt.getVbyListEx=function(t,e,r,n,i){var s,a,o=dt;return-1==(s=o.getIdxbyListEx(t,e,r,n))?null:(a=o.getV(t,s),"03"==t.substr(s,2)&&!1!==i&&(a=a.substr(2)),a)},dt.getInt=function(t,e,r){null==r&&(r=-1);try{var n=t.substr(e,2);if("02"!=n&&"03"!=n)return r;var i=dt.getV(t,e);return"02"==n?parseInt(i,16):Yt(i)}catch(t){return r}},dt.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:Xt(dt.getV(t,e))}catch(t){return r}},dt.getOIDName=function(t,e,r){null==r&&(r=null);try{var n=dt.getOID(t,e,r);if(n==r)return r;var i=lt.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(t){return r}},dt.getString=function(t,e,r){null==r&&(r=null);try{return Pt(dt.getV(t,e))}catch(t){return r}},dt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],n=t.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var s=t.substr(2),a=[],o=0;o0&&(c=c+"."+h.join(".")),c},dt.dump=function(t,e,r,n){var i=dt,s=i.getV,a=i.dump,o=i.getChildIdx,h=t;t instanceof lt.asn1.ASN1Object&&(h=t.tohex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var c,l=e.ommit_long_octet;if("01"==(c=h.substr(r,2)))return"00"==(f=s(h,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==c)return n+"INTEGER "+u(f=s(h,r),l)+"\n";if("03"==c){var f=s(h,r);if(i.isASN1HEX(f.substr(2))){var p=n+"BITSTRING, encapsulates\n";return p+=a(f.substr(2),e,0,n+" ")}return n+"BITSTRING "+u(f,l)+"\n"}if("04"==c){f=s(h,r);if(i.isASN1HEX(f)){p=n+"OCTETSTRING, encapsulates\n";return p+=a(f,e,0,n+" ")}return n+"OCTETSTRING "+u(f,l)+"\n"}if("05"==c)return n+"NULL\n";if("06"==c){var d=s(h,r),g=lt.asn1.ASN1Util.oidHexToInt(d),y=lt.asn1.x509.OID.oid2name(g),v=g.replace(/\./g," ");return""!=y?n+"ObjectIdentifier "+y+" ("+v+")\n":n+"ObjectIdentifier ("+v+")\n"}if("0a"==c)return n+"ENUMERATED "+parseInt(s(h,r))+"\n";if("0c"==c)return n+"UTF8String '"+Ft(s(h,r))+"'\n";if("13"==c)return n+"PrintableString '"+Ft(s(h,r))+"'\n";if("14"==c)return n+"TeletexString '"+Ft(s(h,r))+"'\n";if("16"==c)return n+"IA5String '"+Ft(s(h,r))+"'\n";if("17"==c)return n+"UTCTime "+Ft(s(h,r))+"\n";if("18"==c)return n+"GeneralizedTime "+Ft(s(h,r))+"\n";if("1a"==c)return n+"VisualString '"+Ft(s(h,r))+"'\n";if("1e"==c)return n+"BMPString '"+Ut(s(h,r))+"'\n";if("30"==c){if("3000"==h.substr(r,4))return n+"SEQUENCE {}\n";p=n+"SEQUENCE\n";var m=e;if((2==(S=o(h,r)).length||3==S.length)&&"06"==h.substr(S[0],2)&&"04"==h.substr(S[S.length-1],2)){y=i.oidname(s(h,S[0]));var x=JSON.parse(JSON.stringify(e));x.x509ExtName=y,m=x}for(var w=0;w4?{enum:{hex:y}}:{enum:parseInt(y,16)};if("30"==d||"31"==d)return g[p[d]]=function(t){for(var e=[],n=a(t,0),i=0;i31)&&(128==(192&r)&&(31&r)==n))}catch(t){return!1}},dt.isASN1HEX=function(t){var e=dt;if(t.length%2==1)return!1;var r=e.getVblen(t,0),n=t.substr(0,2),i=e.getL(t,0);return t.length-n.length-i.length==2*r},dt.checkStrictDER=function(t,e,r,n,i){var s=dt;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!lt.lang.String.isHex(t))throw new Error("not hex string");r=t.length,i=(n=t.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var a=s.getVblen(t,e);if(a>n)throw new Error("value of L too long than hex: idx="+e);var o=s.getTLV(t,e),h=o.length-2-s.getL(t,e).length;if(h!==2*a)throw new Error("V string length and L's value not the same:"+h+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);var u=t.substr(e,2);if("02"===u){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(u,16)){for(var l=s.getVblen(t,e),f=0,p=s.getChildIdx(t,e),d=0;d0&&t.push(new n({tag:"a3",obj:new u(e.ext)})),new lt.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},ne(lt.asn1.x509.TBSCertificate,lt.asn1.ASN1Object),lt.asn1.x509.Extensions=function(t){lt.asn1.x509.Extensions.superclass.constructor.call(this);var e=lt.asn1,r=e.DERSequence,n=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e-1&&t.push(new n({int:this.pathLen}));var e=new i({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},ne(lt.asn1.x509.BasicConstraints,lt.asn1.x509.Extension),lt.asn1.x509.CRLDistributionPoints=function(t){lt.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=lt.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var n=[],i=0;i0&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},ne(lt.asn1.x509.PolicyInformation,lt.asn1.ASN1Object),lt.asn1.x509.PolicyQualifierInfo=function(t){lt.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=lt.asn1,r=e.DERSequence,n=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},ne(lt.asn1.x509.PolicyQualifierInfo,lt.asn1.ASN1Object),lt.asn1.x509.UserNotice=function(t){lt.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=lt.asn1.DERSequence,r=(lt.asn1.DERInteger,lt.asn1.x509.DisplayText),n=lt.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},ne(lt.asn1.x509.UserNotice,lt.asn1.ASN1Object),lt.asn1.x509.NoticeReference=function(t){lt.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=lt.asn1.DERSequence,r=lt.asn1.DERInteger,n=lt.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var i=[],s=this.params.noticenum,a=0;a0)for(var t=0;t0;i++){var s=e.shift();if(!0===r){var a=(n.pop()+","+s).replace(/\\,/g,",");n.push(a),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return n=n.map((function(t){return t.replace("/","\\/")})),n.reverse(),"/"+n.join("/")},lt.asn1.x509.X500Name.ldapToOneline=function(t){return lt.asn1.x509.X500Name.ldapToCompat(t)},lt.asn1.x509.RDN=function(t){lt.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=lt.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new lt.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=lt.asn1.x509.RDN.parseString(t),r=0;r0)for(var t=0;t0;i++){var s=e.shift();if(!0===r){var a=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(a),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var o=!1,h=[];for(i=0;n.length>0;i++){s=n.shift();if(!0===o){var u=h.pop();if(s.match(/"$/)){a=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(a),o=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(o=!0)}return h},lt.asn1.x509.AttributeTypeAndValue=function(t){lt.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=lt,r=e.asn1,n=r.DERSequence,i=r.DERUTF8String,s=r.DERPrintableString,a=r.DERTeletexString,o=r.DERIA5String,h=r.DERVisibleString,u=r.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new h({str:e});if("bmp"==t)return new u({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=lt.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new n({array:[t,e]});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},ne(lt.asn1.x509.AttributeTypeAndValue,lt.asn1.ASN1Object),lt.asn1.x509.SubjectPublicKeyInfo=function(t){lt.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=lt,r=e.asn1,n=r.DERInteger,i=r.DERBitString,s=r.DERObjectIdentifier,a=r.DERSequence,o=r.ASN1Util.newObject,h=r.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new a({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{if(t instanceof st){var e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof lt.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof lt.crypto.DSA){r=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:r});var a=new n({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+a.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},ne(lt.asn1.x509.SubjectPublicKeyInfo,lt.asn1.ASN1Object),lt.asn1.x509.Time=function(t){lt.asn1.x509.Time.superclass.constructor.call(this);var e=lt.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if("string"==typeof t&&(t={str:t}),null==t||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new n(t.str))):e="gen"==this.type?new n:new r,null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},lt.asn1.x509.Time_bak=function(t){lt.asn1.x509.Time_bak.superclass.constructor.call(this);var e=lt.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new n(this.timeParams):"utc"==this.type?new r:new n,this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},ne(lt.asn1.x509.Time,lt.asn1.ASN1Object),lt.asn1.x509.AlgorithmIdentifier=function(t){lt.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=lt.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var n in r)n===this.nameAlg&&(t=r[n]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var i=[this.asn1Alg];null!==this.asn1Params&&i.push(this.asn1Params);var s=new e.DERSequence({array:i});return this.hTLV=s.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var n=this.nameAlg.toLowerCase();"withdsa"!==n.substr(-7,7)&&"withecdsa"!==n.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},ne(lt.asn1.x509.AlgorithmIdentifier,lt.asn1.ASN1Object),lt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},lt.asn1.x509.GeneralName=function(t){lt.asn1.x509.GeneralName.superclass.constructor.call(this);var e=lt.asn1,r=e.x509,n=r.X500Name,i=r.OtherName,s=e.DERIA5String,a=(e.DERPrintableString,e.DEROctetString),o=e.DERTaggedObject,h=e.ASN1Object,u=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,c=!1;if(void 0!==r.other)t="a0",e=new i(r.other);else if(void 0!==r.rfc822)t="81",e=new s({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new s({str:r.dns});else if(void 0!==r.dn)t="a4",c=!0,e="string"==typeof r.dn?new n({str:r.dn}):r.dn instanceof lt.asn1.x509.X500Name?r.dn:new n(r.dn);else if(void 0!==r.ldapdn)t="a4",c=!0,e=new n({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,f;t="a4",c=!0;var p=null;if(void 0!==r.certsubj?(l=!1,f=r.certsubj):(l=!0,f=r.certissuer),f.match(/^[0-9A-Fa-f]+$/),-1!=f.indexOf("-----BEGIN ")&&(p=Nt(f)),null==p)throw new Error("certsubj/certissuer not cert");var d,g=new he;g.hex=p,d=l?g.getIssuerHex():g.getSubjectHex(),(e=new h).hTLV=d}else if(void 0!==r.uri)t="86",e=new s({str:r.uri});else{if(void 0===r.ip)throw new u("improper params");var y;t="87";var v=r.ip;try{if(v.match(/^[0-9a-f]+$/)){var m=v.length;if(8!=m&&16!=m&&32!=m&&64!=m)throw"err";y=v}else y=Mt(v)}catch(t){throw new u("malformed IP address: "+r.ip+":"+t.message)}e=new a({hex:y})}return new o({tag:t,explicit:c,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},ne(lt.asn1.x509.GeneralName,lt.asn1.ASN1Object),lt.asn1.x509.GeneralNames=function(t){lt.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=lt.asn1;this.setByParamArray=function(t){for(var r=0;r0){for(var r=s(t.valhex,e[0]),n=c(r,0),i=[],a=0;a1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=c(t.valhex,0);if(r.length>0){var a=n.getOID(t.valhex,r[0]);t.oid=a}if(r.length>1){var o=new e,h=c(t.valhex,r[1]),u=s(t.valhex,h[0]),l=o.getAlgorithmIdentifierName(u);t.alg=l;var f=i(t.valhex,h[1]);t.hash=f}delete t.valhex},this.setSigningCertificateV2=function(t){var e=c(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),n=c(r,0),i=[],a=0;a1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.getESSCertID=function(t){var e={},r=c(t,0);if(r.length>0){var n=i(t,r[0]);e.hash=n}if(r.length>1){var a=s(t,r[1]),o=this.getIssuerSerial(a);null!=o.serial&&(e.serial=o.serial),null!=o.issuer&&(e.issuer=o.issuer)}return e},this.getESSCertIDv2=function(e){var n={},a=c(e,0);if(a.length<1||3o+1){var l=s(e,a[o+1]),f=this.getIssuerSerial(l);n.issuer=f.issuer,n.serial=f.serial}return n},this.getIssuerSerial=function(t){var e={},n=c(t,0),a=s(t,n[0]),o=r.getGeneralNames(a)[0].dn;e.issuer=o;var h=i(t,n[1]);return e.serial={hex:h},e},this.getCertificateSet=function(t){for(var e=c(t,0),r=[],n=0;n=0;a--)i+=n[a];return i}if("string"==typeof t&&null!=s[t])return ee([t],s);if("object"==typeof t&&null!=t.length)return ee(t,s);throw new e("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new n({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},ne(lt.asn1.tsp.PKIFailureInfo,lt.asn1.ASN1Object),lt.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},lt.asn1.tsp.SimpleTSAAdapter=function(t){var e=lt,r=e.asn1.tsp,n=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var i=n(t,e);this.params.econtent.content.messageImprint={alg:e,hash:i},this.params.econtent.content.serial={int:this.serial++};var s=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},ne(lt.asn1.tsp.SimpleTSAAdapter,lt.asn1.tsp.AbstractTSAAdapter),lt.asn1.tsp.FixedTSAAdapter=function(t){var e=lt,r=e.asn1.tsp,n=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var i=n(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:i},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},ne(lt.asn1.tsp.FixedTSAAdapter,lt.asn1.tsp.AbstractTSAAdapter),lt.asn1.tsp.TSPUtil=new function(){},lt.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new lt.asn1.tsp.TimeStampToken(t)},lt.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new lt.asn1.tsp.TSPParser).getTimeStampReq(t)},lt.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new lt.asn1.tsp.TSPParser).getMessageImprint(t)},lt.asn1.tsp.TSPParser=function(){Error;var t=new he,e=dt,r=e.getV,n=e.getTLV,i=e.getIdxbyList,s=(e.getTLVbyListEx,e.getChildIdx),a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],o={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=s(t,0);if(1==e.length)return this.getPKIStatusInfo(n(t,e[0]));if(e.length>1){var r=this.getPKIStatusInfo(n(t,e[0])),i=n(t,e[1]),a=this.getToken(i);return a.statusinfo=r,a}},this.getToken=function(t){var e=(new lt.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var r=e.content.hex,n=this.getTSTInfo(r);e.content=n}},this.getTSTInfo=function(e){var i={},a=s(e,0),o=r(e,a[1]);i.policy=Xt(o);var h=n(e,a[2]);i.messageImprint=this.getMessageImprint(h);var u=r(e,a[3]);i.serial={hex:u};var c=r(e,a[4]);i.genTime={str:Ft(c)};var l=0;if(a.length>5&&"30"==e.substr(a[5],2)){var f=n(e,a[5]);i.accuracy=this.getAccuracy(f),l++}a.length>5+l&&"01"==e.substr(a[5+l],2)&&("ff"==r(e,a[5+l])&&(i.ordering=!0),l++);if(a.length>5+l&&"02"==e.substr(a[5+l],2)){var p=r(e,a[5+l]);i.nonce={hex:p},l++}if(a.length>5+l&&"a0"==e.substr(a[5+l],2)){var d=n(e,a[5+l]);d="30"+d.substr(2),pGeneralNames=t.getGeneralNames(d);var g=pGeneralNames[0].dn;i.tsa=g,l++}if(a.length>5+l&&"a1"==e.substr(a[5+l],2)){var y=n(e,a[5+l]);y="30"+y.substr(2);var v=t.getExtParamArray(y);i.ext=v,l++}return i},this.getAccuracy=function(t){for(var e={},n=s(t,0),i=0;i1&&"30"==t.substr(i[1],2)){var c=n(t,i[1]);e.statusstr=this.getPKIFreeText(c),o++}if(i.length>o&&"03"==t.substr(i[1+o],2)){var l=n(t,i[1+o]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],n=s(t,0),i=0;i0&&(u=u+"."+o.join(".")),u}catch(t){return null}}var Zt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function Yt(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16);if(r>7)return-1;var n=t.substr(2),i=parseInt(n,16).toString(2);"0"==i&&(i="00000000"),i=i.slice(0,0-r);var s=parseInt(i,2);return NaN==s?-1:s}catch(t){return-1}}function Qt(t){if("number"!=typeof t)return null;if(t<0)return null;var e=Number(t).toString(2),r=8-e.length%8;8==r&&(r=0),e+=Zt("",r,"0");var n=parseInt(e,2).toString(16);return n.length%2==1&&(n="0"+n),"0"+r+n}function te(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7=0;n--)s+=i[n];return s}function re(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var n=0;ni)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="0001",a="00"+n,o="",h=i-4-a.length,u=0;u=0)return!1;if(n.compareTo(r.ONE)<0||n.compareTo(s)>=0)return!1;var o=n.modInverse(s),h=t.multiply(o).mod(s),u=e.multiply(o).mod(s);return a.multiply(h).add(i.multiply(u)).getX().toBigInteger().mod(s).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),n=e.toByteArraySigned(),i=[];return i.push(2),i.push(r.length),(i=i.concat(r)).push(2),i.push(n.length),(i=i.concat(n)).unshift(i.length),i.unshift(48),i},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(n),s:r.fromByteArrayUnsigned(i)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var n=this.ecparams.n;return{r:r.fromByteArrayUnsigned(t.slice(1,33)).mod(n),s:r.fromByteArrayUnsigned(t.slice(33,65)).mod(n),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===u(t))throw new Error("not ASN.1 hex string");var e,r,n;try{e=h(t,0,["[0]",0],"06"),r=h(t,0,[1],"04");try{n=h(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=a(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,n,i;try{h(t,0,[1,0],"06"),r=h(t,0,[1,1],"06"),n=h(t,0,[2,0,1],"04");try{i=h(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=a(r),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(n),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,n;try{h(t,0,[0,0],"06"),r=h(t,0,[0,1],"06"),n=h(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=a(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},this.readCertPubKeyHex=function(t,r){if(!1===u(t))throw new e("not ASN.1 hex string");var n,i;try{n=h(t,0,[0,5,0,1],"06"),i=h(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=a(n),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},lt.crypto.ECDSA.parseSigHex=function(t){var e=lt.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new b(e.r,16),s:new b(e.s,16)}},lt.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=dt,r=e.getChildIdx,n=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var i=r(t,0);if(2!=i.length)throw new Error("signature shall have two elements");var s=i[0],a=i[1];if("02"!=t.substr(s,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(a,2))throw new Error("2nd item not ASN.1 integer");return{r:n(t,s),s:n(t,a)}},lt.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=lt.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,n=e.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(n.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==r.substr(0,2)&&(r=r.substr(2)),"00"==n.substr(0,2)&&(n=n.substr(2));var i=Math.max(r.length,n.length);return(r=("000000"+r).slice(-i))+(n=("000000"+n).slice(-i))}if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),r.length%32==30&&(r="00"+r),n.length%32==30&&(n="00"+n),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(n.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+n},lt.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),r=t.substr(t.length/2);return lt.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},lt.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new b(t,16),n=new b(e,16);return lt.crypto.ECDSA.biRSSigToASN1Sig(r,n)},lt.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=lt.asn1,n=new r.DERInteger({bigint:t}),i=new r.DERInteger({bigint:e});return new r.DERSequence({array:[n,i]}).tohex()},lt.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==lt&<||(lt={}),void 0!==lt.crypto&<.crypto||(lt.crypto={}),lt.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new b(t,16)}this.getByName=function(r){var n=r;if(void 0!==e[n]&&(n=e[r]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,i,s,a,o,h,u,c,l,f,p,d){t[n]={};var g=r(s),y=r(a),v=r(o),m=r(h),x=r(u),w=new ut(g,y,v),S=w.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=i,t[n].keycharlen=2*Math.ceil(i/8),t[n].curve=w,t[n].G=S,t[n].n=m,t[n].h=x,t[n].oid=p,t[n].info=d;for(var b=0;b1?new b(n,16):null,u=new b(i,16),this.setPrivate(s,a,o,h,u)},this.setPublic=function(t,e,r,n){this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=n,this.x=null},this.setPublicHex=function(t,e,r,n){var i,s,a,o;i=new b(t,16),s=new b(e,16),a=new b(r,16),o=new b(n,16),this.setPublic(i,s,a,o)},this.signWithMessageHash=function(t){var e=this.p,r=this.q,n=this.g,i=(this.y,this.x),s=lt.crypto.Util.getRandomBigIntegerMinToMax(b.ONE.add(b.ONE),r.subtract(b.ONE)),a=new b(t.substr(0,r.bitLength()/4),16),o=n.modPow(s,e).mod(r),h=s.modInverse(r).multiply(a.add(i.multiply(o))).mod(r);return lt.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:o}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,n=this.q,i=this.g,s=this.y,a=this.parseASN1Signature(e),o=a[0],h=a[1],u=new b(t.substr(0,n.bitLength()/4),16);if(b.ZERO.compareTo(o)>0||o.compareTo(n)>0)throw"invalid DSA signature";if(b.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=o.multiply(c).mod(n);return 0==i.modPow(l,r).multiply(s.modPow(f,r)).mod(r).mod(n).compareTo(o)},this.parseASN1Signature=function(t){try{return[new n(e(t,0,[0],"02"),16),new n(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var n,i,s,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[1],"02"),i=e(t,0,[2],"02"),s=e(t,0,[3],"02"),a=e(t,0,[4],"02"),o=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(n,i,s,a,o)},this.readPKCS8PrvKeyHex=function(t){var n,i,s,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[1,1,0],"02"),i=e(t,0,[1,1,1],"02"),s=e(t,0,[1,1,2],"02"),a=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(n,i,s,null,a)},this.readPKCS8PubKeyHex=function(t){var n,i,s,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[0,1,0],"02"),i=e(t,0,[0,1,1],"02"),s=e(t,0,[0,1,2],"02"),a=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(n,i,s,a)},this.readCertPubKeyHex=function(t,n){var i,s,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,5,0,1,0],"02"),s=e(t,0,[0,5,0,1,1],"02"),a=e(t,0,[0,5,0,1,2],"02"),o=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(i,s,a,o)}};var ie=function(){var t=function(t,r,n){return e(g.AES,t,r,n)},e=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),a=g.enc.Hex.parse(n),o={};o.key=s,o.iv=a,o.ciphertext=i;var h=t.decrypt(o,s,{iv:a});return g.enc.Hex.stringify(h)},r=function(t,e,r){return n(g.AES,t,e,r)},n=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),a=g.enc.Hex.parse(n),o=t.encrypt(i,s,{iv:a}),h=g.enc.Hex.parse(o.toString());return g.enc.Base64.stringify(h)},i={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,n){return e(g.TripleDES,t,r,n)},eproc:function(t,e,r){return n(g.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,n){return e(g.DES,t,r,n)},eproc:function(t,e,r){return n(g.DES,t,e,r)},keylen:8,ivlen:8}},s=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var i=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(i=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(i=t.indexOf("\n\n"),s=1);var a=t.indexOf("-----END");if(-1!=i&&-1!=a){var o=t.substring(i+2*s,a-s);o=o.replace(/\s+/g,""),e.data=o}return e},a=function(t,e,r){for(var n=r.substring(0,16),s=g.enc.Hex.parse(n),a=g.enc.Utf8.parse(e),o=i[t].keylen+i[t].ivlen,h="",u=null;;){var c=g.algo.MD5.create();if(null!=u&&c.update(u),c.update(a),c.update(s),u=c.finalize(),(h+=g.enc.Hex.stringify(u)).length>=2*o)break}var l={};return l.keyhex=h.substr(0,2*i[t].keylen),l.ivhex=h.substr(2*i[t].keylen,2*i[t].ivlen),l},o=function(t,e,r,n){var s=g.enc.Base64.parse(t),a=g.enc.Hex.stringify(s);return(0,i[e].proc)(a,r,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return a(t,e,r)},decryptKeyB64:function(t,e,r,n){return o(t,e,r,n)},getDecryptedKeyHex:function(t,e){var r=s(t),n=(r.type,r.cipher),i=r.ivsalt,h=r.data,u=a(n,e,i).keyhex;return o(h,n,u,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,n,s){var o="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===i[n])throw new Error("KEYUTIL unsupported algorithm: "+n);if(void 0===s||null==s){var h=function(t){var e=g.lib.WordArray.random(t);return g.enc.Hex.stringify(e)}(i[n].ivlen);s=h.toUpperCase()}var u=function(t,e,r,n){return(0,i[e].eproc)(t,r,n)}(e,n,a(n,r,s).keyhex,s);o="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+n+","+s+"\r\n",o+="\r\n",o+=u.replace(/(.{64})/g,"$1\r\n"),o+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=dt,r=e.getChildIdx,n=e.getV,i={},s=r(t,0);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+s.length);i.ciphertext=n(t,s[1]);var a=r(t,s[0]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+a.length);if("2a864886f70d01050d"!=n(t,a[0]))throw new Error("this only supports pkcs5PBES2");var o=r(t,a[1]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+o.length);var h=r(t,o[1]);if(2!=h.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length);if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(t,h[1]);var u=r(t,o[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=n(t,u[0]))throw new Error("this only supports pkcs5PBKDF2");var c=r(t,u[1]);if(c.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length);i.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{i.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return i},getPBKDF2KeyHexFromParam:function(t,e){var r=g.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,i=g.PBKDF2(e,r,{keySize:6,iterations:n});return g.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=Nt(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=ie.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=g.enc.Hex.parse(n.ciphertext);var a=g.enc.Hex.parse(i),o=g.enc.Hex.parse(n.encryptionSchemeIV),h=g.TripleDES.decrypt(s,a,{iv:o});return g.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=dt,r=e.getChildIdx,n=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var a=r(t,s[1]);if(2!=a.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(a[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(t,a[0]),"06"==t.substr(a[1],2)&&(i.algparam=n(t,a[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Nt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new st;else if("2a8648ce380401"==r.algoid)e=new lt.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new lt.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=dt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new st;else if("2a8648ce380401"===r)e=new lt.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new lt.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=dt,r=e.getChildIdx,n=e.getV,i={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var s=r(t,0);if(2!=s.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(s[0],2))throw new Error("malformed RSA key(code:003)");if(i.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw new Error("malformed RSA key(code:004)");return i.e=n(t,s[1]),i},parsePublicPKCS8Hex:function(t){var e=dt,r=e.getChildIdx,n=e.getV,i={algparam:null},s=r(t,0);if(2!=s.length)throw new Error("outer DERSequence shall have 2 elements: "+s.length);var a=s[0];if("30"!=t.substr(a,2))throw new Error("malformed PKCS8 public key(code:001)");var o=r(t,a);if(2!=o.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(i.algoid=n(t,o[0]),"06"==t.substr(o[1],2)?i.algparam=n(t,o[1]):"30"==t.substr(o[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,o[1],[0],"02"),i.algparam.q=e.getVbyList(t,o[1],[1],"02"),i.algparam.g=e.getVbyList(t,o[1],[2],"02")),"03"!=t.substr(s[1],2))throw new Error("malformed PKCS8 public key(code:004)");return i.key=n(t,s[1]).substr(2),i}}}();ie.getKey=function(t,e,r){var n=(y=dt).getChildIdx,i=(y.getV,y.getVbyList),s=lt.crypto,a=s.ECDSA,o=s.DSA,h=st,u=Nt,c=ie;if(void 0!==h&&t instanceof h)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new a({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new a({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new h).setPublic(t.n,t.e),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(T=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(T=new h).setPrivate(t.n,t.e,t.d),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(T=new o).setPublic(t.p,t.q,t.g,t.y),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(T=new o).setPrivate(t.p,t.q,t.g,t.y,t.x),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new h).setPublic(bt(t.n),bt(t.e)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(T=new h).setPrivateEx(bt(t.n),bt(t.e),bt(t.d),bt(t.p),bt(t.q),bt(t.dp),bt(t.dq),bt(t.qi)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(T=new h).setPrivate(bt(t.n),bt(t.e),bt(t.d)),T;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(I=new a({curve:t.crv})).ecparams.keycharlen,f="04"+("0000000000"+bt(t.x)).slice(-l)+("0000000000"+bt(t.y)).slice(-l);return I.setPublicKeyHex(f),I}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(I=new a({curve:t.crv})).ecparams.keycharlen,f="04"+("0000000000"+bt(t.x)).slice(-l)+("0000000000"+bt(t.y)).slice(-l);var p=("0000000000"+bt(t.d)).slice(-l);return I.setPublicKeyHex(f),I.setPrivateKeyHex(p),I}if("pkcs5prv"===r){var d,g=t,y=dt;if(9===(d=n(g,0)).length)(T=new h).readPKCS5PrvKeyHex(g);else if(6===d.length)(T=new o).readPKCS5PrvKeyHex(g);else{if(!(d.length>2&&"04"===g.substr(d[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(T=new a).readPKCS5PrvKeyHex(g)}return T}if("pkcs8prv"===r)return T=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return he.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return he.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Nt(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=i(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),w=i(R,0,[2],"02"),S=i(R,0,[3],"02"),E=i(R,0,[4],"02"),F=i(R,0,[5],"02");return(T=new o).setPrivate(new b(x,16),new b(w,16),new b(S,16),new b(E,16),new b(F,16)),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){m=u(t,"EC PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),P=new st;return P.readPKCS5PrvKeyHex(A),P}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I,T=i(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),D=i(R,0,[2,0],"06"),C=i(R,0,[3,0],"03").substr(2);if(void 0===lt.crypto.OID.oidhex2name[D])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+D);return(I=new a({curve:lt.crypto.OID.oidhex2name[D]})).setPublicKeyHex(C),I.setPrivateKeyHex(T),I.isPublic=!1,I}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;x=i(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),w=i(R,0,[2],"02"),S=i(R,0,[3],"02"),E=i(R,0,[4],"02"),F=i(R,0,[5],"02");return(T=new o).setPrivate(new b(x,16),new b(w,16),new b(S,16),new b(E,16),new b(F,16)),T}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},ie.generateKeypair=function(t,e){if("RSA"==t){var r=e;(a=new st).generate(r,"10001"),a.isPrivate=!0,a.isPublic=!0;var n=new st,i=a.n.toString(16),s=a.e.toString(16);return n.setPublic(i,s),n.isPrivate=!1,n.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=n,o}if("EC"==t){var a,o,h=e,u=new lt.crypto.ECDSA({curve:h}).generateKeyPairHex();return(a=new lt.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),a.setPrivateKeyHex(u.ecprvhex),a.isPrivate=!0,a.isPublic=!1,(n=new lt.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=n,o}throw new Error("unknown algorithm: "+t)},ie.getPEM=function(t,e,r,n,i,s){var a=lt,o=a.asn1,h=o.DERObjectIdentifier,u=o.DERInteger,c=o.ASN1Util.newObject,l=o.x509.SubjectPublicKeyInfo,f=a.crypto,p=f.DSA,d=f.ECDSA,y=st;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function x(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==y&&t instanceof y||void 0!==p&&t instanceof p||void 0!==d&&t instanceof d)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(E=new l(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==y&&t instanceof y&&(void 0===r||null==r)&&1==t.isPrivate)return Rt(E=v(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===r||null==r)&&1==t.isPrivate){var w=new h({name:t.curveName}).tohex(),S=m(t).tohex(),b="";return b+=Rt(w,"EC PARAMETERS"),b+=Rt(S,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate)return Rt(E=x(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==y&&t instanceof y&&void 0!==r&&null!=r&&1==t.isPrivate){var E=v(t).tohex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",E,r,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate){E=m(t).tohex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",E,r,n,s)}if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate){E=x(t).tohex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",E,r,n,s)}var F=function(t,e){var r=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).tohex()},A=function(t,e){var r=g.lib.WordArray.random(8),n=g.lib.WordArray.random(8),i=g.PBKDF2(e,r,{keySize:6,iterations:100}),s=g.enc.Hex.parse(t),a=g.TripleDES.encrypt(s,i,{iv:n})+"",o={};return o.ciphertext=a,o.pbkdf2Salt=g.enc.Hex.stringify(r),o.pbkdf2Iter=100,o.encryptionSchemeAlg="DES-EDE3-CBC",o.encryptionSchemeIV=g.enc.Hex.stringify(n),o};if("PKCS8PRV"==e&&null!=y&&t instanceof y&&1==t.isPrivate){var P=v(t).tohex();E=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:P}}]}).tohex();return void 0===r||null==r?Rt(E,"PRIVATE KEY"):Rt(S=F(E,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){var I={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};"string"==typeof t.pubKeyHex&&I.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]});P=new c(I).tohex(),E=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:P}}]}).tohex();return void 0===r||null==r?Rt(E,"PRIVATE KEY"):Rt(S=F(E,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate){P=new u({bigint:t.x}).tohex(),E=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:P}}]}).tohex();return void 0===r||null==r?Rt(E,"PRIVATE KEY"):Rt(S=F(E,r),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},ie.getKeyFromCSRPEM=function(t){var e=Nt(t,"CERTIFICATE REQUEST");return ie.getKeyFromCSRHex(e)},ie.getKeyFromCSRHex=function(t){var e=ie.parseCSRHex(t);return ie.getKey(e.p8pubkeyhex,null,"pkcs8pub")},ie.parseCSRHex=function(t){var e=dt,r=e.getChildIdx,n=e.getTLV,i={},s=t;if("30"!=s.substr(0,2))throw new Error("malformed CSR(code:001)");var a=r(s,0);if(a.length<1)throw new Error("malformed CSR(code:002)");if("30"!=s.substr(a[0],2))throw new Error("malformed CSR(code:003)");var o=r(s,a[0]);if(o.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(s,o[2]),i},ie.getKeyID=function(t){var e=ie,r=dt;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var n=Nt(e.getPEM(t)),i=r.getIdxbyList(n,0,[1]),s=r.getV(n,i).substring(2);return lt.crypto.Util.hashHex(s,"sha1")},ie.getJWK=function(t,e,r,n,i){var s,a,o={},h=lt.crypto.Util.hashHex;if("string"==typeof t)s=ie.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(a=Nt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof he?(s=t.getPublicKey(),a=t.hex):s=t}if(s instanceof st&&s.isPrivate)o.kty="RSA",o.n=St(s.n.toString(16)),o.e=St(s.e.toString(16)),o.d=St(s.d.toString(16)),o.p=St(s.p.toString(16)),o.q=St(s.q.toString(16)),o.dp=St(s.dmp1.toString(16)),o.dq=St(s.dmq1.toString(16)),o.qi=St(s.coeff.toString(16));else if(s instanceof st&&s.isPublic)o.kty="RSA",o.n=St(s.n.toString(16)),o.e=St(s.e.toString(16));else if(s instanceof lt.crypto.ECDSA&&s.isPrivate){if("P-256"!==(c=s.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);var u=s.getPublicKeyXYHex();o.kty="EC",o.crv=c,o.x=St(u.x),o.y=St(u.y),o.d=St(s.prvKeyHex)}else if(s instanceof lt.crypto.ECDSA&&s.isPublic){var c;if("P-256"!==(c=s.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);u=s.getPublicKeyXYHex();o.kty="EC",o.crv=c,o.x=St(u.x),o.y=St(u.y)}if(null==o.kty)throw new Error("unsupported keyinfo");return s.isPrivate||1==e||(o.kid=lt.jws.JWS.getJWKthumbprint(o)),null!=a&&1!=r&&(o.x5c=[x(a)]),null!=a&&1!=n&&(o.x5t=xt(x(h(a,"sha1")))),null!=a&&1!=i&&(o["x5t#S256"]=xt(x(h(a,"sha256")))),o},ie.getJWKFromKey=function(t){return ie.getJWK(t,!0,!0,!0,!0)},st.getPosArrayOfChildrenFromHex=function(t){return dt.getChildIdx(t,0)},st.getHexValueArrayOfChildrenFromHex=function(t){var e,r=dt.getV,n=r(t,(e=st.getPosArrayOfChildrenFromHex(t))[0]),i=r(t,e[1]),s=r(t,e[2]),a=r(t,e[3]),o=r(t,e[4]),h=r(t,e[5]),u=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(n,i,s,a,o,h,u,c,l),e},st.prototype.readPrivateKeyFromPEMString=function(t){var e=Nt(t),r=st.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},st.prototype.readPKCS5PrvKeyHex=function(t){var e=st.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},st.prototype.readPKCS8PrvKeyHex=function(t){var e,r,n,i,s,a,o,h,u=dt,c=u.getVbyListEx;if(!1===u.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),r=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),a=c(t,0,[2,0,6],"02"),o=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,n,i,s,a,o,h)},st.prototype.readPKCS5PubKeyHex=function(t){var e=dt,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(t,n[0]),s=r(t,n[1]);this.setPublic(i,s)},st.prototype.readPKCS8PubKeyHex=function(t){var e=dt;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},st.prototype.readCertPubKeyHex=function(t,e){var r,n;(r=new he).readCertHex(t),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};function se(t,e){for(var r="",n=e/4-t.length,i=0;i>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function oe(t){for(var e in lt.crypto.Util.DIGESTINFOHEAD){var r=lt.crypto.Util.DIGESTINFOHEAD[e],n=r.length;if(t.substring(0,n)==r)return[e,t.substring(n)]}return[]}function he(t){var e,r=dt,n=r.getChildIdx,i=r.getV,s=(r.dump,r.parse),a=r.getTLV,o=r.getVbyList,h=r.getVbyListEx,u=r.getTLVbyList,c=r.getTLVbyListEx,l=r.getIdxbyList,f=r.getIdxbyListEx,p=r.getVidx,d=r.getInt,g=r.oidname,y=r.hextooidstr,v=Nt,m=Error;try{e=lt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var t=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(t,0,[0]),r=d(e,0);if(r<0||20?e:void 0}catch(t){return}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=re(t,"seq"),n=0;n0?e:void 0}catch(t){return}},this._asn1ToNoticeNum=function(t){try{for(var e=re(t,"seq"),r=[],n=0;n1){var o=a(t,s[1]),h=this.getGeneralName(o);null!=h.uri&&(i.uri=h.uri)}if(s.length>2){var u=a(t,s[2]);"0101ff"==u&&(i.reqauth=!0),"010100"==u&&(i.reqauth=!1)}return i},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"subjectDirectoryAttributes"};e&&(n.critical=!0);try{for(var i=s(t),o=[],h=0;h0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=u(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&(-1!=f(this.hex,0,[0,"[3]"])&&(t=c(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=n(t,0),i=0;i0&&(u=new Array(r),(new rt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=Pt(h(It("\0\0\0\0\0\0\0\0"+i+u))),l=[];for(n=0;n>8*o-a&255;for(d[0]&=~g,n=0;nn)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var s=oe(i.replace(/^1f+00/,""));if(0==s.length)return!1;var a=s[0],o=s[1],h=function(t){return lt.crypto.Util.hashString(t,a)}(t);return o==h},st.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=nt(e,16);if(r.bitLength()>this.n.bitLength())return 0;var n=oe(this.doPublic(r).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},st.prototype.verifyPSS=function(t,e,r,n){var i,s=(i=It(t),lt.crypto.Util.hashHex(i,r));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,r,n)},st.prototype.verifyWithMessageHashPSS=function(t,e,r,n){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,s=new b(e,16),a=function(t){return lt.crypto.Util.hashHex(t,r)},o=Pt(t),h=o.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw new Error("invalid salt length");if(c>8*c-u&255;if(f.charCodeAt(0)&d)throw new Error("bits beyond keysize not zero");var g=ae(p,f.length,a),y=[];for(i=0;i0)&&-1==(":"+r.join(":")+":").indexOf(":"+g+":"))throw"algorithm '"+g+"' not accepted in the list";if("none"!=g&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=ie.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[d.alg])throw"unsupported alg name: "+g;if("none"==(v=s.jwsalg2sigalg[g]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),p==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var x,w=null;try{w=h.concatSigToASN1Sig(p)}catch(t){return!1}return(x=new c({alg:v})).init(e),x.updateString(f),x.verify(w)}return(x=new c({alg:v})).init(e),x.updateString(f),x.verify(p)},lt.jws.JWS.parse=function(t){var e,r,n,i=t.split("."),s={};if(2!=i.length&&3!=i.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=i[0],r=i[1],3==i.length&&(n=i[2]),s.headerObj=lt.jws.JWS.readSafeJSONString(pt(e)),s.payloadObj=lt.jws.JWS.readSafeJSONString(pt(r)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=pt(r):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=bt(n)),s},lt.jws.JWS.verifyJWT=function(t,e,r){var n=lt.jws,i=n.JWS,s=i.readSafeJSONString,a=i.inArray,o=i.includedArray;if(!$t(t))return!1;var h=t.split(".");if(3!=h.length)return!1;var u=h[0],c=h[1],l=(bt(h[2]),s(pt(u))),f=s(pt(c));if(void 0===l.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!a(l.alg,r.alg))return!1;if(void 0!==f.iss&&"object"==typeof r.iss&&!a(f.iss,r.iss))return!1;if(void 0!==f.sub&&"object"==typeof r.sub&&!a(f.sub,r.sub))return!1;if(void 0!==f.aud&&"object"==typeof r.aud)if("string"==typeof f.aud){if(!a(f.aud,r.aud))return!1}else if("object"==typeof f.aud&&!o(f.aud,r.aud))return!1;var p=n.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(p=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+r.gracePeriodi&&this.aHeader.pop(),this.aSignature.length>i&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},lt.crypto.ECDSA,lt.crypto.DSA,lt.crypto.Signature,lt.crypto.MessageDigest,lt.crypto.Mac,lt.crypto.Cipher,lt.crypto,lt.asn1,lt.jws,lt.lang},334:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(582);n.__exportStar(r(643),e),n.__exportStar(r(533),e),n.__exportStar(r(89),e),n.__exportStar(r(881),e),n.__exportStar(r(293),e)},643:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PhoenixService=void 0;const n=r(533),i=r(89),s=r(881),a={appName:"phoenix-frontend-tooling",className:"PhoenixService"};e.PhoenixService=class{name;ufsAkmid="APM0228201";config;updateConfig;getConfig;isAuthorMode;putConfig;additionalRequestHeaders={};constructor(t,e){if(this.config=e||(0,i.findConfig)(t),!this.config)throw new Error(`${t.toString()} was not found. Unable to start the service.`);a.className=`${a.className}-${this.config.serviceName}`,this.isAuthorMode=this.setAuthorMode(),this.name=Symbol.for(`${this.config.serviceName} Service`)}setAuthorMode(){const t=document.querySelector("body");return"EDIT"===t?.dataset.wcmMode}async getData(t){if(!this.getConfig)throw new Error("No Get Method Defined");const e=t?.queryParameters?`?${t.queryParameters}`:"",r=`${this.getConfig?.basePath}/${this.getConfig?.servicePath}`+e,n=this.getConfig&&this.getConfig.headers?this.getConfig.headers:{},i=new Headers(n).get("transactionId")||window.uuid.v4(),s=performance.now();try{const e=await fetch(r,{method:"GET",body:JSON.stringify(t?.body),headers:n}),o=performance.now()-s,h=await e.json();if(e.ok){const s=await this.createClearwaterLog(i,JSON.stringify(t?.body),"GET",o,e.status,"Success",JSON.stringify(e),e.headers,`Success submitting the query to ${r} recieved ${e.status}`,r,this.convertHeadersToRecord(n));return window.phoenix.log.clearwater(s,a),h}{const s=`Error in GETDATA path of ${r} with response status of ${e.status}.`,h=await this.createClearwaterLog(i,JSON.stringify(t?.body),"GET",o,e.status,"Fault",JSON.stringify(e),e.headers,s,r,this.convertHeadersToRecord(n));throw window.phoenix.log.clearwater(h,a),new Error(s)}}catch(t){throw await this.handleErrorLogging(i,t,e,s,r,"GET",this.convertHeadersToRecord(n)),t}}async updateData(t){if(!this.updateConfig)throw new Error("No Update Method Defined");const e=t?.queryParameters?`?${t.queryParameters}`:"",r=`${this.updateConfig?.basePath}/${this.updateConfig?.servicePath}`+e,n={...this.updateConfig?.headers?this.updateConfig.headers:{},...this.additionalRequestHeaders},i=new Headers(n).get("transactionId")||window.uuid.v4(),s=performance.now();try{const e=await fetch(r,{method:"POST",body:JSON.stringify(t?.body),headers:n}),o=performance.now()-s,h=await e.json();if(e.ok){const s=await this.createClearwaterLog(i,JSON.stringify(t?.body),"POST",o,e.status,"Success",JSON.stringify(e),e.headers,`Success submitting the query to ${r} recieved ${e.status}`,r,this.convertHeadersToRecord(n));return window.phoenix.log.clearwater(s,a),h}{const s=`Error in UPDATEDATA path of ${r} recieved response status of ${e.status}.`,h=await this.createClearwaterLog(i,JSON.stringify(t?.body),"POST",o,e.status,"Fault",JSON.stringify(e),e.headers,s,r,this.convertHeadersToRecord(n));throw window.phoenix.log.clearwater(h,a),new Error(s)}}catch(e){throw await this.handleErrorLogging(i,e,JSON.stringify(t?.body),s,r,"POST",this.convertHeadersToRecord(n)),e}}async makeGqlQuery(t,e,r){const n=await(0,s.ufsHeaders)(),i=window.phoenix.configs?.apiDomainsConfigs?.graphql?.targetDomain,o=window.phoenix.configs?.apiDomainsConfigs?.graphql?.apiPath;i&&o||window.phoenix.log.warning("Warning: Missing GQL Domain or Path from configs",{...a,methodName:"makeGqlQuery"});const h=performance.now(),u=JSON.stringify({query:t,variables:e}),c={Accept:"application/json",...n,...r};try{const e=await fetch(`${i}${o}`,{method:"POST",headers:c,credentials:"omit",body:u}),r=performance.now()-h,s=await e.json();if(e.ok){const t=await this.createClearwaterLog(n["activity-id"],u,"POST",r,200,"Success",JSON.stringify(s),e.headers,"GQL success",`${i}${o}`,c);return window.phoenix.log.clearwater(t,{...a,methodName:"makeGQLQuery"}),s}{const h=`Error in GraphQL call of ${t} recieved response status of ${e.status}.`,l=await this.createClearwaterLog(n["activity-id"],u,"POST",r,200,"Error",JSON.stringify(s),e.headers,"GQL failure",`${i}${o}`,c);throw window.phoenix.log.clearwater(l,{...a,methodName:"makeGQLQuery"}),new Error(h)}}catch(t){throw await this.handleErrorLogging(n["activity-id"],t,u,h,`${i}${o}`,"POST",c),t}}async makePutRequest(t){if(!this.putConfig)throw new Error("No Update Method Defined");const e=t?.queryParameters?`?${t.queryParameters}`:"",r=`${this.putConfig?.basePath}/${this.putConfig?.servicePath}`+e,n=this.putConfig&&this.putConfig.headers?this.putConfig.headers:{},i=new Headers(n).get("transactionId")||window.uuid.v4(),s=performance.now();try{const e=await fetch(r,{method:"PUT",body:JSON.stringify(t?.body),headers:n}),o=performance.now()-s,h=await e.json();if(e.ok){const s=await this.createClearwaterLog(i,JSON.stringify(t?.body),"PUT",o,e.status,"Success",JSON.stringify(e),e.headers,`Success submitting the query to ${r} recieved ${e.status}`,r,this.convertHeadersToRecord(n));return window.phoenix.log.clearwater(s,a),h}{const s=`Error in UPDATEDATA path of ${r} recieved response status of ${e.status}.`,h=await this.createClearwaterLog(i,JSON.stringify(t?.body),"PUT",o,e.status,"Fault",JSON.stringify(e),e.headers,s,r,this.convertHeadersToRecord(n));throw window.phoenix.log.clearwater(h,a),new Error(s)}}catch(e){const o=await this.createClearwaterLog(i,JSON.stringify(t?.body),"POST",performance.now()-s,599,"Fault","unknown",null,`Error submitting the query to ${r}`,r,this.convertHeadersToRecord(n));throw window.phoenix.log.clearwater(o,a),e}}async createClearwaterLog(t,e,r,i,s,o,h,u,c,l,f,p){const d={};u&&u.forEach(((t,e)=>{d[e]=t}));const g=window.Cookies.get("id_token")||window.Cookies.get("a_token");let y="";if(g)try{const t=await(0,n.decodeJWT)(g);y=t?.usn||""}catch(t){window.phoenix.log.warning("Error decoding token:",a,t)}return{RequestId:t,RequestTime:(new Date).toString(),Sender:y,SenderType:"USER",Method:r,Receiver:this.ufsAkmid,Duration:i,ResponseStatusCode:s,Result:o,RequestHeaders:f||{},RequestBody:e,ResponseHeaders:d,ResponseBody:h,TargetEndpoint:window.location.origin+l,msg:c,obj:p}}convertHeadersToRecord(t){const e={},r=t;for(const t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e}async handleErrorLogging(t,e,r,n,i,s,o){if(e instanceof Error&&!e?.message.match(/with response status/gi)){const e=await this.createClearwaterLog(t,r,s,performance.now()-n,599,"Fault","unknown",null,`Error submitting the query to ${i}`,i,o);window.phoenix.log.clearwater(e,a)}throw e}async start(){this.isAuthorMode?window.phoenix.log.warning("Author Mode detected, stopping api calls!",a):this.setupMethods()}stop(){}setupMethods(){this.config?.methods.forEach((t=>{switch(t.method){case"GET":this.getConfig=t;break;case"POST":this.updateConfig=t;break;case"PUT":this.putConfig=t}}))}}},293:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},533:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeJWT=void 0;e.decodeJWT=async t=>{try{const e=t.split(".")[1],r=e?.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(window.atob(r).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join(""));return Promise.resolve(JSON.parse(n))}catch(e){throw new Error(`Unable to parse token! ${e}; Using provided token: ${t}`)}}},89:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.findConfig=void 0,e.findConfig=function(t){if(window?.phoenix?.configs?.serviceConfigs){const e=window.phoenix.configs.serviceConfigs.filter((e=>e.serviceName.toLowerCase()===t.toString().toLowerCase()));return 1===e.length?e[0]:void 0}}},881:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ufsHeaders=void 0;const n=r(533);let i={"Content-Type":"application/json","session-id":"","interaction-id":"","workflow-id":"","sub-workflow-id":"","activity-id":"","channel-id":"WEB","application-id":"APM0226219-PHX","service-transaction-id":"",timestamp:"","origin-application-id":"APM0226219-PHX"};e.ufsHeaders=async t=>{if(t){const e=window.phoenix.configs?.usGraphConfigs?.find((e=>e?.intent?.toUpperCase()===t.toUpperCase()))?.headers;e&&(i=e)}const e=await window.phoenix.persistedState.get("PDP_TRANSACTION_TYPE");i["workflow-id"]=e||"UPGRADE","UPGRADE"===i["workflow-id"]?i["interaction-id"]="097ebb03-fdde-454b-89bb-257d74677019":i["interaction-id"]=window.uuid.v4();const r=document?.head?.dataset.analyticsPagePagename;i["sub-workflow-id"]=r||"unknown",i["service-transaction-id"]=window.uuid.v4(),i["activity-id"]=window.uuid.v4();const s=window.Cookies.get("id_token")?window.Cookies.get("id_token"):window.Cookies.get("a_token");if(s){const t=await(0,n.decodeJWT)(s);t&&t?.usn&&(i["session-id"]=t.usn),i["session-id"]||(i["session-id"]=window.uuid.v4())}else i["session-id"]=window.uuid.v4();return i.timestamp=(new Date).toISOString(),i}},252:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(582);n.__exportStar(r(144),e),n.__exportStar(r(421),e),n.__exportStar(r(864),e),n.__exportStar(r(157),e),n.__exportStar(r(816),e),n.__exportStar(r(429),e),n.__exportStar(r(935),e),n.__exportStar(r(658),e),n.__exportStar(r(46),e),n.__exportStar(r(122),e),n.__exportStar(r(475),e),n.__exportStar(r(327),e),n.__exportStar(r(556),e),n.__exportStar(r(892),e)},144:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},421:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},864:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t){const e={appName:"phoenix",className:Symbol.keyFor(t)??"Error no ClassName"};window.phoenix.log.info(`${t.toString()} Starting`,e)}handleErrors(){}}},157:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PhoenixService=void 0;var n=r(334);Object.defineProperty(e,"PhoenixService",{enumerable:!0,get:function(){return n.PhoenixService}})},816:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r,...n){if(!t)throw"startFunc is not defined";e||(e="unassigned"),r||(r="unassigned");const i={appName:r,className:e};let s=null;try{return s=n?new t(...n):new t,window.phoenix.log.debug(`Started ${e}.`,i),s}catch(t){return window.phoenix.log.error(`Error Starting service ${t}`,i,{exception:t}),s}}},429:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.productTypeFromCategory=e.productFamilyCategoryMapper=void 0;e.productFamilyCategoryMapper=t=>{const e=t.pathname;if(e.match(/\/cellphone\/|\/cellphones\/|\/cell-phones\/|\/cell-phone\/|\/cell-phones$/gi))return"CELLPHONES";if(e.match(/\/tablet\/|\/tablets\/|\/tablets$/gi))return"TABLETS";if(e.match(/\/smart-watch\/|\/smartwatches\/|\/smart-watches$/gi))return"SMARTWATCHES";if(e.match(/\/hotspot-iot-connected-device\/|\/hotspots-iot-connected-devices\/|\/hotspot-iot-connected-devices\/|\/hotspots-iot-connected-devices$|\/hotspots_iot_connected_devices$/gi))return"HOTSPOTS_IOT_CONNECTED_DEVICES";return e.match(/\/accessory\/|\/accessoriess\/|\/accessories$/gi)?"ACCESSORIES":null};e.productTypeFromCategory=t=>{if("CELLPHONES"===t)return"Cell Phone";if("TABLETS"===t)return"Tablet";if("SMARTWATCHES"===t)return"Smart Watch";if("HOTSPOTS_IOT_CONNECTED_DEVICES"===t)return"HotSpot & IoT";return"ACCESSORIES"===t?"Accessory":null}},935:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.correlationIdCheck=void 0,e.correlationIdCheck=async function(t){let e=await window.localforage.getItem("HSIcorrelationId");e||(e=window.uuid.v4(),await window.localforage.setItem("HSIcorrelationId",e)),t.correlationId=e}},658:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeJWT=void 0;var n=r(334);Object.defineProperty(e,"decodeJWT",{enumerable:!0,get:function(){return n.decodeJWT}})},46:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.arrayBufferFromBase64=e.downloadPDFromBase64=void 0;e.downloadPDFromBase64=(t,r)=>{const n=(0,e.arrayBufferFromBase64)(t),i=new Blob([n],{type:"application/pdf"}),s=window.URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=`${r}.pdf`,a.click(),window.URL.revokeObjectURL(s),a.remove()};e.arrayBufferFromBase64=t=>{const e=window.atob(t),r=e.length,n=new Uint8Array(r);for(let t=0;t{window.phoenix.bus.publish("GRAPHQL","GRAPHQL_REQUEST",{payload:{query:t.replace(/(\r\n|\n|\r)/gm,"").trim(),identifier:e,variables:r,headers:n,channel:i,topic:s}})};e.getGraphQLError=t=>{const e=t?.error,r=e?.[0]?.message;return{code:e?.[0]?.extensions?.code||e?.code,message:r}}},475:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.applyScrollMarginTop=void 0,e.applyScrollMarginTop=function(t={}){const{marginTop:e,timeout:r}=t,n=()=>{const t=(parseInt(document.documentElement.style.getPropertyValue("--js--header-height-overall"),10)||0)+parseInt(e||"0",10);if(t>0){const e=document.createElement("style");e.innerHTML=`:target { scroll-margin-top: ${t}px; }`,document.head.appendChild(e)}};"number"==typeof r?setTimeout(n,r):n()}},327:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.safeJsonParse=void 0,e.safeJsonParse=function(t){try{return JSON.parse(t)}catch(e){return window.phoenix.log.warning(`Error parsing JSON string ${t}`,{appName:"phoenix-frontend-tooling",className:"ES Module - JSON utils",methodName:"safeJsonParse"}),{}}}},556:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.formatPhoneNumber=void 0,e.formatPhoneNumber=function(t){if(null==t)return;const e=t.replace(/\D/g,"");if(10!==e.length)return;const r=e.match(/^(\d{3})(\d{3})(\d{4})$/);return`(${r[1]}) ${r[2]}-${r[3]}`}},892:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ufsHeaders=void 0;var n=r(334);Object.defineProperty(e,"ufsHeaders",{enumerable:!0,get:function(){return n.ufsHeaders}})},582:function(t,e,r){"use strict";r.r(e),r.d(e,{__addDisposableResource:function(){return B},__assign:function(){return s},__asyncDelegator:function(){return A},__asyncGenerator:function(){return F},__asyncValues:function(){return P},__await:function(){return E},__awaiter:function(){return d},__classPrivateFieldGet:function(){return R},__classPrivateFieldIn:function(){return O},__classPrivateFieldSet:function(){return N},__createBinding:function(){return y},__decorate:function(){return o},__disposeResources:function(){return j},__esDecorate:function(){return u},__exportStar:function(){return v},__extends:function(){return i},__generator:function(){return g},__importDefault:function(){return C},__importStar:function(){return D},__makeTemplateObject:function(){return I},__metadata:function(){return p},__param:function(){return h},__propKey:function(){return l},__read:function(){return x},__rest:function(){return a},__runInitializers:function(){return c},__setFunctionName:function(){return f},__spread:function(){return w},__spreadArray:function(){return b},__spreadArrays:function(){return S},__values:function(){return m}});var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=0;o--)(i=t[o])&&(a=(s<3?i(a):s>3?i(e,r,a):i(e,r))||a);return s>3&&a&&Object.defineProperty(e,r,a),a}function h(t,e){return function(r,n){e(r,n,t)}}function u(t,e,r,n,i,s){function a(t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("Function expected");return t}for(var o,h=n.kind,u="getter"===h?"get":"setter"===h?"set":"value",c=!e&&t?n.static?t:t.prototype:null,l=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),f=!1,p=r.length-1;p>=0;p--){var d={};for(var g in n)d[g]="access"===g?{}:n[g];for(var g in n.access)d.access[g]=n.access[g];d.addInitializer=function(t){if(f)throw new TypeError("Cannot add initializers after decoration has completed");s.push(a(t||null))};var y=(0,r[p])("accessor"===h?{get:l.get,set:l.set}:l[u],d);if("accessor"===h){if(void 0===y)continue;if(null===y||"object"!=typeof y)throw new TypeError("Object expected");(o=a(y.get))&&(l.get=o),(o=a(y.set))&&(l.set=o),(o=a(y.init))&&i.unshift(o)}else(o=a(y))&&("field"===h?i.unshift(o):l[u]=o)}c&&Object.defineProperty(c,n.name,l),f=!0}function c(t,e,r){for(var n=arguments.length>2,i=0;i0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function x(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return a}function w(){for(var t=[],e=0;e1||o(t,e)}))})}function o(t,e){try{(r=i[t](e)).value instanceof E?Promise.resolve(r.value.v).then(h,u):c(s[0][2],r)}catch(t){c(s[0][3],t)}var r}function h(t){o("next",t)}function u(t){o("throw",t)}function c(t,e){t(e),s.shift(),s.length&&o(s[0][0],s[0][1])}}function A(t){var e,r;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,i){e[n]=t[n]?function(e){return(r=!r)?{value:E(t[n](e)),done:!1}:i?i(e):e}:i}}function P(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=m(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,i,(e=t[r](e)).done,e.value)}))}}}function I(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var T=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function D(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&y(e,t,r);return T(e,t),e}function C(t){return t&&t.__esModule?t:{default:t}}function R(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}function N(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r}function O(t,e){if(null===e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof t?e===t:t.has(e)}function B(t,e,r){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose]}if("function"!=typeof n)throw new TypeError("Object not disposable.");t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e}var H="function"==typeof SuppressedError?SuppressedError:function(t,e,r){var n=new Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n};function j(t){function e(e){t.error=t.hasError?new H(e,t.error,"An error was suppressed during disposal."):e,t.hasError=!0}return function r(){for(;t.stack.length;){var n=t.stack.pop();try{var i=n.dispose&&n.dispose.call(n.value);if(n.async)return Promise.resolve(i).then(r,(function(t){return e(t),r()}))}catch(t){e(t)}}if(t.hasError)throw t.error}()}e.default={__extends:i,__assign:s,__rest:a,__decorate:o,__param:h,__metadata:p,__awaiter:d,__generator:g,__createBinding:y,__exportStar:v,__values:m,__read:x,__spread:w,__spreadArrays:S,__spreadArray:b,__await:E,__asyncGenerator:F,__asyncDelegator:A,__asyncValues:P,__makeTemplateObject:I,__importStar:D,__importDefault:C,__classPrivateFieldGet:R,__classPrivateFieldSet:N,__classPrivateFieldIn:O,__addDisposableResource:B,__disposeResources:j}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={exports:{}};return t[n](s,s.exports,r),s.exports}r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){"use strict";function t(t){this.message=t}t.prototype=new Error,t.prototype.name="InvalidCharacterError";var e="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var r=String(e).replace(/=+$/,"");if(r.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,a=0,o="";i=r.charAt(a++);~i&&(n=s%4?64*n+i:i,s++%4)?o+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function n(t){var r=t.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(e(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(r)}catch(t){return e(r)}}function i(t){this.message=t}i.prototype=new Error,i.prototype.name="InvalidTokenError";var s=function(t,e){if("string"!=typeof t)throw new i("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(n(t.split(".")[r]))}catch(t){throw new i("Invalid token specified: "+t.message)}};class a{static metroDomainRegex=/.+.metrobyt-mobile.com$/;startApp(){this.refreshAuthState(),this.getOauthJwt(),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","REFRESH_AUTH_STATE",this.refreshAuthState.bind(this)),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","REFRESH_OAUTH_TOKEN",this.refreshAuthState.bind(this)),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","FETCH_JWT",this.getOauthJwt.bind(this))}refreshAuthState(t){const e=this.mapAuthState();document.body.setAttribute("data-auth-state",e),window.phoenix.bus.publish("PLATFORM_AUTHORIZATION","SET_AUTH_STATE",{payload:{authState:e}},t)}setMetroAuthState(){return window.Cookies.get("isUserSignedIn")?"authenticated":"prospect"}mapAuthState(){const t=window.location.host;if(a.metroDomainRegex.test(t))return this.setMetroAuthState();const e=window.Cookies.get("id_token");if(!e)return"prospect";const r=s(e);return!r.exp||1e3*r.exp<=Date.now()?"previously-authenticated":"authenticated"}getOauthJwt(){try{const t=window.Cookies.get("id_token");if(t){const e=s(t);window.phoenix.bus.publish("PLATFORM_AUTHORIZATION","SET_JWT",{payload:{token:e}})}else window.phoenix.bus.publish("PLATFORM_AUTHORIZATION","SET_JWT",{payload:{token:null}})}catch(t){window.phoenix.log.error("Error retrieving JWT",{appName:"phoenix-platform",className:"auth-state.service"},t)}}}r(166);const o="Authlib";function h(t){return(new TextEncoder).encode(t)}function u(t){return btoa(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(t){return String.fromCharCode(...t)}function l(t){return u(c(t))}async function f(t){const e=h(t),r=await crypto.subtle.digest("SHA-256",e);return u(c(new Uint8Array(r)))}function p(t=0,e=["","-","-","-","-","",""]){if(tt in r)))throw new Error("Missing ehts, should have either a_token, id_token or Authorization ehts");return r.uri=a,r["http-method"]=o,"GET"!==o&&(i||s)&&(r.body=JSON.stringify(i||s)),r}}async function v(t){const{db:e,objectStoreName:r,operation:n,value:i,key:s}=t,a=e.transaction(r,n).objectStore(r);if("readwrite"===n){const t=a.add(i,s);return await m(t),i}return m(a.get(s))}function m(t){return new Promise(((e,r)=>{t.onsuccess=t=>{e(t.target.result)},t.onerror=()=>{r("db operation error")}}))}async function x(t,e){return t.close(),new Promise((t=>t(e)))}async function w(t,e){const r={dbName:t?.dbName||"key-db",version:t?.version||1,objectStoreName:t?.objectStoreName||"key-store",storeKeyName:t?.storeKeyName||"key-pair"};try{const t=await async function(t){return new Promise(((e,r)=>{let n;try{n=indexedDB.open(t.dbName,t.version),n.onupgradeneeded=()=>{n.result.createObjectStore(t.objectStoreName)},n.onsuccess=()=>{const t=n.result;e(t)}}catch(t){const e=new Error("Error in connecting to the DB");e.stack=t.stack,r(e)}}))}(r),n={key:r.storeKeyName,db:t,objectStoreName:r.objectStoreName,operation:"readonly"},i=await v(n);if(i)return x(t,i);{const n=await async function(t={}){return crypto.subtle.generateKey(t.algo||{name:"ECDSA",namedCurve:"P-256"},t.isExportable||!1,t.operations||["sign","verify"])}(e),i={key:r.storeKeyName,value:n,db:t,objectStoreName:r.objectStoreName,operation:"readwrite"};return x(t,await v(i))}}catch(t){const e=new Error("Error getting crypto key pair");return e.stack=t.stack,Promise.reject(e)}}class S extends y{constructor(t){super(t)}sign(t,e,r){const{privateKey:n,publicKey:i}=r,s=`${u(t)}.${u(e)}`,a=h(s),o=this.getKeyAlgoForSigning(i);return crypto.subtle.sign(o,n,a).then((t=>{const e=l(new Uint8Array(t));return`${s}.${e}`}))}constructJwsHeader(t){if(!t)throw new Error(`${o}:: Public Key can't be null or undefined`);let e=this.getKeyAlgorithm(t);if(!e)throw new Error(`${o}:: Public Key not supported`);const r={type:"JWT",alg:this.getJwtHeaderAlg(e)};return"2"!==this.version||(r.jwk=t,t.kid)?Promise.resolve(r):g(t).then((e=>(t.kid=e,{...r,jwk:t})))}generateSha256Digest(t){return f(t)}getKeyAlgoForSigning(t){let e;const r=this.getKeyAlgorithm(t)?.toUpperCase(),n={name:"SHA-256"};if(r&&r.includes("P-"))e={name:"ECDSA",hash:n};else{if("RS256"!==r)throw new Error(`${o}:: Key algo not supported`);e="RSASSA-PKCS1-v1_5"}return e}getKeyAlgorithm(t){if(t&&"object"==typeof t){const{crv:e,alg:r}=t;return r||e}}getJwtHeaderAlg(t){return{"P-256":"ES256","P-384":"ES384","P-512":"ES512",RS256:"RS256"}[t]}}async function b(t,e,r){try{let n=!1;const i=function(t){try{const[e,r]=t.split(".");return{header:JSON.parse(atob(e)),payload:JSON.parse(atob(r))}}catch(t){const e=new Error(`${o}:: Error decoding idToken`);throw e.stack=t.stack,e}}(t),{tmocnf:s,cnf:a}=i.payload,h=await async function(t){const e=await crypto.subtle.exportKey("jwk",t),r=await g(e);return{...e,kid:r}}(e),{kid:u}=h;if(r&&s){if(u&&s[u]){const t=await f(JSON.stringify(h));n=s[u]===t}}else if(a){const{keys:t,kid:e}=JSON.parse(a);n=t?.length>0?t.some((({kid:t})=>t===u)):e===u}return r?{isValid:n,publicKey:h}:{isValid:n}}catch(t){const e=new Error(`${o}:: Error validating kid in token`);throw e.stack=t.stack,e}}class E{static interceptedUris=[/\/(self-service-.*?|commerce\/v3)\/.*/i,/\/customer-credit\/.*/i,/\/(self-service-flex\/v1\/subscriber\/account)\/.*/i,/\/(billing-customer-management)\/.*/i];static xAuthOrigUris=[/\/(billing-customer-management|self-service-unifiedservices)\/.*/i,/\/(self-service-acc)\/.*/i];static nonInterceptedUris=[/\/self-service-.*?\/v1\/oauth/i,/\/self-service-content\/.*/i,/\/self-service-sigma-account\/.*/i];static popTokenEnabledUris=[/\/(self-service-unifiedservices)\/.*/i,/\/(self-service-bh-download)\/.*/i,/\/(self-service-contextual)\/.*/i];authorizationToken;networkPause=new AbortController;startApp(){window.fetchIntercept.register({request:this.requestInterceptor.bind(this)}),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","SET_OAUTH_TOKEN",(t=>{this.authorizationToken=t?.payload?.oauthToken,this.authorizationToken&&""!==this.authorizationToken.toString().trim()&&this.networkPause.abort()}))}requestInterceptor(t,e){return this.shouldIntercept(t)?this.networkPause.signal.aborted?this.applyHeaders(t,e):new Promise((r=>{this.networkPause.signal.addEventListener("abort",(()=>{r(this.applyHeaders(t,e))}))})):[t,e]}async applyHeaders(t,e){if(t instanceof Request&&(t.headers.set("authorization","Bearer "+this.authorizationToken),this.shouldAddXOrigAuthHeader(t)&&t.headers.set("x-auth-originator",this.authorizationToken)),e&&e.headers?e.headers instanceof Headers?(e.headers.set("authorization","Bearer "+this.authorizationToken),this.shouldAddXOrigAuthHeader(t)&&e.headers.set("x-auth-originator",this.authorizationToken)):e.headers instanceof Array?(e.headers.push(["authorization","Bearer "+this.authorizationToken]),this.shouldAddXOrigAuthHeader(t)&&e.headers.push(["x-auth-originator",this.authorizationToken])):(e.headers.authorization="Bearer "+this.authorizationToken,this.shouldAddXOrigAuthHeader(t)&&(e.headers["x-auth-originator"]=this.authorizationToken)):e&&!e.headers?(e.headers={authorization:"Bearer "+this.authorizationToken},this.shouldAddXOrigAuthHeader(t)&&(e.headers={...e.headers,"x-auth-originator":this.authorizationToken})):e||(e={headers:{authorization:"Bearer "+this.authorizationToken}},this.shouldAddXOrigAuthHeader(t)&&(e.headers={...e.headers,"x-auth-originator":this.authorizationToken})),this.shouldAddPopTokenHeader(t)){const r=await w({dbName:"key-db",version:0,objectStoreName:"key-store",storeKeyName:"key-pair"}),{publicKey:n}=r;await this.validateKidToken(n)&&(e.headers={...e.headers,"x-authorization":await this.generatePopToken(t,r,e)})}return[t,e]}isPopTokenFeatureEnabled(){const t=window?.phoenix?.configs?.featureFlags;if(!Array.isArray(t))return!1;const e=t.find((t=>"enablePopToken"===t.key));return e?.enabled||!1}shouldIntercept(t){let e=t;return t instanceof Request&&(e=t.url),E.interceptedUris.findIndex((t=>t.test(e)))>-1&&-1===E.nonInterceptedUris.findIndex((t=>t.test(e)))}shouldAddXOrigAuthHeader(t){let e=t;return t instanceof Request&&(e=t.url),E.xAuthOrigUris.findIndex((t=>t.test(e)))>-1}shouldAddPopTokenHeader(t){if(!this.isPopTokenFeatureEnabled())return!1;let e=t;return t instanceof Request&&(e=t.url),E.popTokenEnabledUris.findIndex((t=>t.test(e)))>-1}async validateKidToken(t){const e={appName:"phoenix-platform",className:"Authorization Fetch Interceptor"},r=await b(this.authorizationToken,t);return!(!r||!r.isValid)||(window.phoenix.log.error("Error Validating KId Token",e),!1)}async generatePopToken(t,e,r){const n={...r},i={...r?.headers}.popUri??t;delete n?.body;const s={...n,url:i},a=await async function(t,e){const{privateKey:r,publicKey:n}=t;let i,s;return r?.extractable&&(i=await crypto.subtle.exportKey(e,r)),s=await crypto.subtle.exportKey(e,n),{privateKey:i||Object.assign(r||{}),publicKey:s}}(e,"jwk"),o=new S("1"),h=S.getEhtsKeyValueMap(s);return await o.buildPopToken(h,a)}}var F=r(252);var A=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},P="object"==typeof global&&global&&global.Object===Object&&global,I="object"==typeof self&&self&&self.Object===Object&&self,T=P||I||Function("return this")(),D=function(){return T.Date.now()},C=/\s/;var R=function(t){for(var e=t.length;e--&&C.test(t.charAt(e)););return e},N=/^\s+/;var O=function(t){return t?t.slice(0,R(t)+1).replace(N,""):t},B=T.Symbol,H=Object.prototype,j=H.hasOwnProperty,k=H.toString,_=B?B.toStringTag:void 0;var V=function(t){var e=j.call(t,_),r=t[_];try{t[_]=void 0;var n=!0}catch(t){}var i=k.call(t);return n&&(e?t[_]=r:delete t[_]),i},L=Object.prototype.toString;var K=function(t){return L.call(t)},M=B?B.toStringTag:void 0;var q=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":M&&M in Object(t)?V(t):K(t)};var U=function(t){return null!=t&&"object"==typeof t};var G=function(t){return"symbol"==typeof t||U(t)&&"[object Symbol]"==q(t)},z=/^[-+]0x[0-9a-f]+$/i,$=/^0b[01]+$/i,J=/^0o[0-7]+$/i,W=parseInt;var X=function(t){if("number"==typeof t)return t;if(G(t))return NaN;if(A(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=A(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=O(t);var r=$.test(t);return r||J.test(t)?W(t.slice(2),r?2:8):z.test(t)?NaN:+t},Z=Math.max,Y=Math.min;var Q=function(t,e,r){var n,i,s,a,o,h,u=0,c=!1,l=!1,f=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var r=n,s=i;return n=i=void 0,u=e,a=t.apply(s,r)}function d(t){var r=t-h;return void 0===h||r>=e||r<0||l&&t-u>=s}function g(){var t=D();if(d(t))return y(t);o=setTimeout(g,function(t){var r=e-(t-h);return l?Y(r,s-(t-u)):r}(t))}function y(t){return o=void 0,f&&n?p(t):(n=i=void 0,a)}function v(){var t=D(),r=d(t);if(n=arguments,i=this,h=t,r){if(void 0===o)return function(t){return u=t,o=setTimeout(g,e),c?p(t):a}(h);if(l)return clearTimeout(o),o=setTimeout(g,e),p(h)}return void 0===o&&(o=setTimeout(g,e)),a}return e=X(e)||0,A(r)&&(c=!!r.leading,s=(l="maxWait"in r)?Z(X(r.maxWait)||0,e):s,f="trailing"in r?!!r.trailing:f),v.cancel=function(){void 0!==o&&clearTimeout(o),u=0,n=h=i=o=void 0},v.flush=function(){return void 0===o?a:y(D())},v};const tt=new E,et=new class{keystore;keyPair;constructor(){this.keystore=window.localforage.createInstance({name:"phx-key-db",driver:[window.localforage.INDEXEDDB,window.localforage.VOLITALEMEMORY],storeName:"phx-key-store"})}async getKeys(){return this.keyPair||(await this.keystore.ready(),this.keyPair=await this.keystore.getItem("key-pair"),this.keyPair||(this.keyPair=await window.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!1,["sign","verify"]),await this.setKeys(this.keyPair))),this.keyPair}async getExportedPublicKey(){const t=await this.getKeys();if(!t||!t.publicKey)return null;const e=await window.crypto.subtle.exportKey("jwk",t.publicKey),r=await this.thumbprintKey(e);return{...e,kid:r}}async setKeys(t){await this.keystore.setItem("key-pair",t)}async thumbprintKey(t){const e='{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV",t.crv||"").replace("X",t.x||"").replace("Y",t.y||""),r=await window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e));return window.btoa(String.fromCharCode(...new Uint8Array(r)))}},rt=new class{cryptoKeyStore;networkController;cookieDomain=/.+.metrobyt-mobile.com$/.test(window.location.host)?".metrobyt-mobile.com":".t-mobile.com";constructor(t){this.cryptoKeyStore=t}async startApp(){await this.refreshOauthToken(),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","REFRESH_OAUTH_TOKEN",this.refreshOauthToken.bind(this))}async refreshOauthToken(t){const e=this.getOauthToken();if("string"==typeof e&&""!==e.trim())return void this.publishOathToken(e,t);if(this.networkController&&!this.networkController.signal.aborted)return;this.networkController=new AbortController;const r=await this.retrieveOauthToken();r&&"string"==typeof r.accessToken&&""!==r.accessToken.trim()?this.publishOathToken(r.accessToken,t):this.publishOathToken(null,t),this.networkController.abort()}getOauthToken(){const t=window.Cookies.get("id_token");if(this.validateOauthToken(t))return t;window.Cookies.remove("id_token",{path:"/",domain:this.cookieDomain}),this.checkForLoginPage();const e=window.Cookies.get("a_token");return this.validateOauthToken(e)?e:(window.Cookies.remove("a_token",{path:"/",domain:this.cookieDomain}),null)}validateOauthToken(t){if(!t)return!1;const e=s(t||"");return!(!e.exp||1e3*e.exp<=Date.now())}checkForLoginPage(){const t=document.querySelector("body"),e=t?.dataset.loginPage;e&&window.location.assign(e)}publishOathToken(t,e){window.phoenix.bus.publish("PLATFORM_AUTHORIZATION","SET_OAUTH_TOKEN",{payload:{oauthToken:t}},e)}async retrieveOauthToken(){let t=!1;return window.phoenix?.checkFeatureFlag&&(t=window.phoenix.checkFeatureFlag("useEOSOauth")),t?await this.retrieveOauthEos():await this.retrieveOauthTos()}getOauthPath(){return window.phoenix.getAppConfig("phoenix-platform.oauth.path")||"/v1/eosoauthmanager/v1/oauth"}async retrieveOauthEos(){const t=await this.cryptoKeyStore.getExportedPublicKey();if(!t)return null;const e=await fetch(this.getOauthPath(),{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({jwk:JSON.stringify(t)})});if(200===e.status){const t=await e.json();if(t?.access_token){const e=s(t?.access_token??"");window.Cookies.set("a_token",t.access_token,{expires:new Date(1e3*(e?.exp||0)),domain:this.cookieDomain,secure:!0})}return{accessToken:t.access_token}}return e.status>299&&this.removeAuthTokens(),null}async retrieveOauthTos(){const t=await this.cryptoKeyStore.getExportedPublicKey();if(!t)return null;const e=window.phoenix.getAppConfig("phoenix-platform.oauth.path")||"/self-service-flex/v1/oauth",r=await fetch(e,{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({jwk:JSON.stringify(t)})});if(200===r.status){const t=await r.json();if(t?.accessToken){const e=s(t?.accessToken||"");return window.Cookies.set("a_token",t.accessToken,{expires:new Date(1e3*(e?.exp||0)),domain:this.cookieDomain,secure:!0}),t}return null}return r.status>299&&this.removeAuthTokens(),null}removeAuthTokens(){window.Cookies.remove("id_token",{path:"/",domain:this.cookieDomain}),window.Cookies.remove("a_token",{path:"/",domain:this.cookieDomain})}}(et),nt=new a,it=new class{networkController;startApp(){window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","REFRESH_LOGIN_SESSION_INFO",this.refreshLoginSessionInfo.bind(this)),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","SET_AUTH_STATE",this.handleSetAuthState.bind(this))}async handleSetAuthState(t){"authenticated"===t?.payload?.authState?await this.refreshLoginSessionInfo(t):await window.localforage.removeItem("loginSessionInfo")}async refreshLoginSessionInfo(t){if(this.networkController&&!this.networkController.signal.aborted)return;this.networkController=new AbortController;const e=window.Cookies.get("id_token"),r=JSON.parse(window.Cookies.get("sharedCacheKey")||"[]");let n=await window.localforage.getItem("loginSessionInfo"),i=!1;Array.isArray(r)&&(i=r.indexOf("userInfo")>-1),n?.idToken&&(n.idToken!==e||i)&&(n=null,await window.localforage.removeItem("loginSessionInfo")),!n&&e&&(n=await this.executeLoginSessionInfoApi(),await window.localforage.setItem("loginSessionInfo",n)),this.publishLoginSessionInfo(n,t),this.networkController.abort()}publishLoginSessionInfo(t,e){window.phoenix.bus.publish("PLATFORM_AUTHORIZATION","SET_LOGIN_SESSION_INFO",{payload:{loginSessionInfo:t}},e)}async executeLoginSessionInfoApi(){const t=await fetch("/self-service-flex/v1/id/usersession");return 200===t.status?await t.json():(401===t.status&&window.Cookies.remove("id_token",{path:"/",domain:".t-mobile.com"}),null)}},st=new class{timeoutDuration;extensionDuration;timeoutModalDuration;timeOutId;modalIntervalId;modalExtensionId;modalRemainingTime;tokenExpiryTime;forceLogout;eventList;constructor(){this.tokenExpiryTime=0,this.timeoutModalDuration=12e4,this.timeoutDuration=36e5,this.extensionDuration=36e5,this.eventList=["keyup","mousedown","mousemove","mouseup","touchmove"],this.timeOutId=0,this.modalIntervalId=1,this.modalExtensionId=2,this.modalRemainingTime=12e4,this.forceLogout=!1}async startApp(){const t=document.querySelector("body");"authenticated"==t?.dataset.authState&&(this.setactivityListeners(),await this.startInacivityTimer(),this.subscribeToEvents())}subscribeToEvents(){window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","CONTINUE_SESSION",this.continueSession.bind(this)),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","END_SESSION",this.endSession.bind(this))}async startInacivityTimer(){await this.checkTokenExpiration(),this.forceLogout=this.forceLogout?this.forceLogout:this.tokenExpiryTime{this.openAuthSessionExtensionModal()}),this.timeoutDuration)}setactivityListeners(){this.eventList.forEach((t=>{document.addEventListener(t,Q((async()=>{window.clearTimeout(this.timeOutId),await this.startInacivityTimer()}),500))}))}openAuthSessionExtensionModal(){const t=document.getElementById("TimeoutModal");if(t){const e=new window.A11yDialog(t),r=document.getElementById("TimeoutModalRemainingTime");window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","CONTINUE_SESSION",(()=>{e.hide()})),window.phoenix.bus.subscribe("PLATFORM_AUTHORIZATION","END_SESSION",(()=>{e.hide()})),e.on("show",(()=>{if(this.forceLogout){const t=document.getElementById("stayLoggedinButton");t&&(t.ariaDisabled="true")}window.phoenix.bus.publish("MODAL","SHOW",{payload:{dialog:{$el:t}}})})),e.on("hide",(()=>{r&&(r.textContent="1:59"),this.modalRemainingTime=12e4,window.phoenix.bus.publish("MODAL","HIDE")})),e.show(),clearTimeout(this.timeOutId),this.modalIntervalId=setInterval((()=>{if(this.modalRemainingTime=this.modalRemainingTime-1e3,this.modalRemainingTime<=0&&window.phoenix.bus.publish("PLATFORM_AUTHORIZATION","END_SESSION"),r){const t=Math.floor(this.modalRemainingTime/6e4%60),e=Math.floor(this.modalRemainingTime/1e3%60),n=`${t}:${e<10?"0":""}${e}`;r.textContent=n}}),1e3)}}startTokenExpiryTimer(){setTimeout((()=>{window.clearTimeout(this.timeOutId),this.forceLogout=!0,this.openAuthSessionExtensionModal()}),this.tokenExpiryTime-this.timeoutModalDuration)}async continueSession(){clearInterval(this.modalIntervalId),clearTimeout(this.timeOutId),this.timeoutDuration=this.extensionDuration,await this.startInacivityTimer(),this.setactivityListeners()}endSession(){window.Cookies.remove("id_token",{path:"/",domain:".t-mobile.com"}),window.location.replace("/signout")}async checkTokenExpiration(){const t=window.Cookies.get("id_token");if(t){const e=await(0,F.decodeJWT)(t),r=(e?.exp?1e3*e.exp:0)-(new Date).getTime();this.tokenExpiryTime=r}}};tt.startApp(),it.startApp(),nt.startApp(),rt.startApp(),st.startApp()}()}();